I try to plot 2 variables against each other selected by user input. But I can not figure it out. I am new to this, not much coding experience.
2 ビュー (過去 30 日間)
古いコメントを表示
% Button pushed function: CheckButton
function CheckButtonPushed(app, event)
%create plot function
t = readtimetable("weather.csv"); %to read table
vars = {'HP','0/100mphsec'};
%get the selected model
selectedModel = app.SelectModelDropDown1.Value;
%find the index of the model in the table
[idx,~] = find(ismember(app.carData2{:,2}, selectedModel));
x = table2array(t(idx,'HP')); %(%specify collumn to assign x));
y = table2array(t(idx,'0/100mphsec')); %(%specify collumn to assign y));
plot (app.UIAxes,x,y);
0 件のコメント
回答 (1 件)
Ishan
2022 年 11 月 30 日
Hi Daniel,
I understand you are trying to plot two variables against each other from a table. You can refer to the following documentation for help with using the plot function: -
However, in your case I observe you are getting an error “unrecognized variable name ‘Data’” which I couldn’t locate in your xlsx file either. If you want to plot data from a table, you can simply store all elements of that particular row or column index you desire in a vector and plot them using the MATLAB plot function. (Do note that A = table2array(T) converts the table or timetable, T, to a homogeneous array, A. The variables in T become columns in A. So, the indexing needs to be done accordingly)
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!