Error using plot: Not Enough Input Arguments
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Reading a Table which was converted from a .csv file into a .xslx file. Trying to plot Output Voltage vs. Sensitivity using "plot' function. Returns error labeled "Error using plot ; Not Enough Input Arguments. " Error is in Line 14. Tried using the readcsv command with the original .csv file and still recieve the same error in the line for the plot function. I will attach my code and the .xlsx file. Any help would be much appriecitated.
CODE:
% Experiment 4
% Computations and Generated Plots
% Group 4-08; Members: Charlie Johnson, Peter Bohlen
clear variables
clc
close all
% Load the xlsx file of saved data from lab 3.1
data1 = readtable('force_transducer_output_4-08.xlsx');
%data1.Properties.VariableNames
x1 = data1.('XTrace1CH1');
y1 = data1.('YTrace1CH1');
% Generate a plot - this is the force transducer plot
figure (1)
plot(x1, y1);
grid on
hold on
title('Force Transducer Output Voltage and Sensitivity');
xlabel('Output Voltage mV');
ylabel('Sensitivity mV/lb');
hold off
Réponse acceptée
Chunru
le 14 Nov 2023
Your data is not in right format. Here is one way to convert the string to number.
% Experiment 4
% Computations and Generated Plots
% Group 4-08; Members: Charlie Johnson, Peter Bohlen
% Load the xlsx file of saved data from lab 3.1
data1 = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1538602/force_transducer_output_4-08.xlsx");
%data1.Properties.VariableNames
x1 = data1.('XTrace1CH1');
y1 = data1.('YTrace1CH1');
whos
x1=str2num(cell2mat(x1));
y1=str2num(cell2mat(y1));
% Generate a plot - this is the force transducer plot
figure (1)
plot(x1, y1);
grid on
hold on
title('Force Transducer Output Voltage and Sensitivity');
xlabel('Output Voltage mV');
ylabel('Sensitivity mV/lb');
hold off
2 commentaires
Chunru
le 14 Nov 2023
Your original xlsx data is not formated as number (instead they are strings) . If you format your xlsx data as number instead of string, you can directry import the data without conversion.
t = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1538637/accelerometer4-08.xlsx")
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!