Matlab for Beginners, Plotting from a matrix!

1 visualización (últimos 30 días)
Justin Jiang
Justin Jiang el 4 de Feb. de 2020
Comentada: David Hill el 6 de Feb. de 2020
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.

Respuestas (1)

David Hill
David Hill el 4 de Feb. de 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 comentarios
Justin Jiang
Justin Jiang el 6 de Feb. de 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 el 6 de Feb. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by