Why is my "plot" function not working?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
T = readtable('ELG3155_LAB3_part2_M_2V.xlsx', 'PreserveVariableNames', true);
x = T.("Time (ms)");
y = T.("Raw speed (mrad/s)");
grid on;
plot(x,y);
When i run this it says there is an error with my plot function, why?
2 commentaires
Matt J
le 26 Mar 2023
We can't run the code (because it's an image and because the data hasn't been provided)
Réponse acceptée
Star Strider
le 26 Mar 2023
Modifié(e) : Star Strider
le 26 Mar 2023
EDIT — (26 Mar 2023 at 10:28)
T = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1336464/ELG3155_LAB3_part2_M_2V.xlsx', 'VariableNamingRule','preserve');
VN = T.Properties.VariableNames;
x = T.("Time (ms)");
y = str2double(T.("Raw speed (mrad/s)"));
figure
plot(x,y)
xlabel(VN{1})
ylabel(VN{3})
grid on
.
2 commentaires
Plus de réponses (1)
Walter Roberson
le 26 Mar 2023
The first row has time 00. That is text not numeric.
Looking at the left justification it looks to me as if the second column is text rather than numeric.
1 commentaire
Walter Roberson
le 26 Mar 2023
I checked in Excel itself, and sure enough, the 00 gives a warning about "Number stored as text", and all of columns 2, 3, 4 report the same thing.
If you use readmatrix() then everything will be converted to numeric.
Note: with default options, the 00 0 0 0 row will be detected as being header and will be skipped.
Voir également
Catégories
En savoir plus sur Spreadsheets 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!