Matlab for Beginners, Plotting from a matrix!

조회 수: 1 (최근 30일)
Justin Jiang
Justin Jiang 2020년 2월 4일
댓글: David Hill 2020년 2월 6일
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.

답변 (1개)

David Hill
David Hill 2020년 2월 4일
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
Justin Jiang
Justin Jiang 2020년 2월 6일
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 2020년 2월 6일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by