Error using plot - not enough input arguments / invalid data argument

조회 수: 23 (최근 30일)
Bl
Bl 2023년 5월 10일
댓글: Tin Truong Chanh 2024년 11월 3일
This is a simple plot I'm trying to get and I don't understand why I'm getting this error. I get the same error if I divide the plot line into two:
"plot (x1A, y1A)
hold on
plot (x1B, y1B)
hold off"

답변 (2개)

VBBV
VBBV 2023년 5월 10일
the variables which are trying to plot are cell array of strings from a table. The plot function call takes NUMERIC (DOUBLE) arrays ONLY to graph the data. If the data in variables contain numbers stored as string data type, then you can use str2double or str2num function to convert them to numeric (double) arrays as shown below
% the below variables are cell array of strings from a table & need to be converted
% to numeric arrays
x1A = str2double(Case1ACalculatingFAAverages{:,1})
x1B = str2double(Case1BCalculatingFAAverages{:,1})
y1A = str2double(Case1ACalculatingFAAverages{:,2})
y1B = str2double(Case1BCalculatingFAAverages{:,2})
% plot them
plot(x1A, y1A, x1B, y1B)

Steven Lord
Steven Lord 2023년 5월 10일
The data you're trying to plot are all string arrays so plot is trying to interpret them as a series of name-value arguments. But you need to give plot some actual data to plot. The following would work:
plot(1:10, 1:10, "Color", "red", "LineStyle", "--")
This wouldn't. You haven't told plot what points to plot.
plot("Color", "red", "LineStyle", "--")
Error using plot
Not enough input arguments.
  댓글 수: 2
Bl
Bl 2023년 5월 10일
I'm not sure I understand. I imported data from an excel file as shown in the Workspace, and am trying to plot those points
Walter Roberson
Walter Roberson 2023년 5월 10일
can you attach the excel file for testing?

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

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by