How to I plot a graph from this data
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nathan
am 7 Okt. 2025 um 17:28
Kommentiert: Star Strider
am 7 Okt. 2025 um 18:33
I have been trying to plot VPV by Depth in the code below:
A= readtable("PREM.txt");
Radius = A(:,1);
Density= A(:,2);
VPV= A(:,3);
VSV= A(:,4);
QK= A(:,5);
QMu= A(:,6);
VPH= A(:,7);
VSH= A(:,8);
eta= A(:,9);
Depth=Radius./6371;
However when I go to use the code plot(VPV,Depth), Matlab responds with:
>> plot(VPV,Depth)
%Red text from below this point
Error using plot
Invalid subscript for Y. A table variable
subscript must be a numeric array containing
real positive integers, a logical array, a
character vector, a string array, a cell array
of character vectors, or a pattern scalar used
to match variable names.
I don't know how to colour the text red so sorry for the confusion if the text colour causes any. If I could receive any help on this matter that would be appreciated.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 7 Okt. 2025 um 17:46
Use curly braces {} to get datafrom a table --
Radius = A{:,1};
Density= A{:,2};
VPV= A{:,3};
VSV= A{:,4};
QK= A{:,5};
QMu= A{:,6};
VPH= A{:,7};
VSH= A{:,8};
eta= A{:,9};
That should work.
.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!