필터 지우기
필터 지우기

Why is my "plot" function not working?

조회 수: 1 (최근 30일)
William
William 2023년 3월 26일
댓글: Star Strider 2023년 3월 26일
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
Matt J
Matt J 2023년 3월 26일
We can't run the code (because it's an image and because the data hasn't been provided)
William
William 2023년 3월 26일
@Matt J there, sorry.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2023년 3월 26일
편집: Star Strider 2023년 3월 26일
Use the str2double function on the last four variables.
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
William
William 2023년 3월 26일
Thank you :)
Star Strider
Star Strider 2023년 3월 26일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2023년 3월 26일
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
Walter Roberson
Walter Roberson 2023년 3월 26일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by