Invalid Data Arguement when plotting

1 view (last 30 days)
Christopher Pineda
Christopher Pineda on 27 Oct 2021
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

Answers (1)

Anshika Chourasia
Anshika Chourasia on 6 Dec 2021
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.

Community Treasure Hunt

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

Start Hunting!