How to I plot a graph from this data
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nathan
le 7 Oct 2025 à 17:28
Commenté : Star Strider
le 7 Oct 2025 à 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 commentaires
Réponse acceptée
Star Strider
le 7 Oct 2025 à 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!