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 Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by