Invalid Data Arguement when plotting

조회 수: 2 (최근 30일)
Christopher Pineda
Christopher Pineda 2021년 10월 27일
답변: Anshika Chourasia 2021년 12월 6일
Using a imported xlsx file with data, been trying to plot 2 different coloumns on 1 graph as shown below. However, I am getting 'error using plot. Invalid data arguement'. Both columns have the same amount of cells.
opts = spreadsheetImportOptions("NumVariables", 6);
% Specify sheet and range
opts.Sheet = "level 1";
opts.DataRange = "A2:F5121";
% Specify column names and types
opts.VariableNames = ["X_Value", "Real", "Imaginary", "Magnitude", "Phase", "Coherence"];
opts.VariableTypes = ["double", "double", "double", "double", "double", "double"];
% Import the data
lab2data = readtable('data29.xlsx');
% Plot Magnitude vs Frequency
M1 = lab2data.Magnitude(1:end);
F1 = lab2data.X_Value(1:end);
figure(1)
hold on
plot(F1, M1)
hold off
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 10월 27일
Why do you construct opts but then not use it?

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

답변 (1개)

Anshika Chourasia
Anshika Chourasia 2021년 12월 6일
Hi,
Please cross-check the correctness of the data file and refer the “readtable” function syntax for creating table from spreadsheets.
If the error stills persist, please provide more information to further investigate into the problem.

카테고리

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