Matlab for Beginners, Plotting from a matrix!

1 view (last 30 days)
Hello, this is building from last post, I am dumb in matlab, and greatly appreciate your help. It should not be hard if I was smart enough.
Capture2.jpeg
23431 20757 21860 47209
23760 21059 22144 47781
25986 22832 23719 50101
This is a matrix, in the first picture, and the numbers above are the first three lines. Please provide code to divide the first three numbers, by the fourth number on each line respectively. Then, you will get three values for each line, simply then plot the three values to X, Y, X dimensions respectively. Result should be graph.
Thank you so much!
I admit I am new and very dumb in matlab.

Answers (1)

David Hill
David Hill on 4 Feb 2020
I assumed you wanted 3d graph (X,Y,Z).
M=%your maxtrix
m=M(:,1:3).*repmat(M(:,4),1,3);
plot3(m(:,1),m(:,2),m(:,3))
  3 Comments
Justin Jiang
Justin Jiang on 6 Feb 2020
thanks for your help,
can you briefly explain the second line?
what does M(: ,1:3) mean? particularly the (:, not sure
what does repmat mean ? is this defining a new matrix
what does M(:,4) mean? does it mean the four line of the matrix?
what does ,1,3) mean? im not sure what this mean
David Hill
David Hill on 6 Feb 2020
M(:,1:3) is all rows and columns 1 through 3 of matrix M.
The repmat() function repeats matrixes or vectors to create a new matrix. You should look at the function yourself in the document section of Matlab. repmat(M(:,4),1,3) makes a matrix of column 4 of M repeated 3 times.

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!