c. Extract the sub-matrix containing all the rows but only columns 2 through 11 and name this matrix grades (to make this work on any size matrix, do not hard-code the 11, but rather use end or size).

2 views (last 30 days)
how do I perform this action ? can any one help ?? reguards phil

Accepted Answer

pfb
pfb on 21 Oct 2014
Hi,
I'm not sure I understand your question. You should provide a concise title and a possibly detailed statement of the problem, not the other way round. Anyway, if I get it right, you have a matrix (say, M) and you want the submatrix containing all the rows and colums 2 trough some c. This matrix should be called grades. This is pretty simple.
L = 20; % size of M, for practical purposes
c = 11; % last column of the submatrix (of course c < L)
% create the submatrix (for practical purposes, you have it from your source)
M = rand(L);
% extract the desired submatrix
grades = M(:,2:c);

More Answers (1)

philip
philip on 21 Oct 2014
basically this is the answer but im not sure how to get there ?
NaN NaN 1.8500 NaN 9.6500 8.9000 3.2625 NaN 4.3625 NaN
  2 Comments
pfb
pfb on 21 Oct 2014
Philip, your questions are too vague. You wrote a 10-entry vector, which I assume is one of the required rows. Or perhaps your matrix has 1 row to begin with, and hence you can also refer to that as a row vector.
Your vector has some NaN (not a number) entries, but I do not know why they are there, nor where you need to get. You did not provide any information about the origin of your matrix, so I'm not sure how you expect people can help you. I guess you get NaNs because you're dividing by zero...
philip
philip on 21 Oct 2014
Hi, im really sorry about that im just a beginner at matlab (trying to learn it), it is a one of the required rows

Sign in to comment.

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!