Matlab for Beginners, Plotting from a matrix!
조회 수: 1 (최근 30일)
이전 댓글 표시
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.
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.
댓글 수: 0
답변 (1개)
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
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.
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!