How to reference a variable in a promt to the user, where the variable will change based on the input csv file

1 ビュー (過去 30 日間)
Brandon Tuttle
Brandon Tuttle 2021 年 6 月 15 日
回答済み: Jeff Miller 2021 年 6 月 16 日
Hi all,
I am having trouble using the promt, but embedding a variable in the prompt text that asks the user wether they want to plot this data or not,
clear all; clc
[file_list, path_n] = uigetfile('.csv', 'select all the files needing to be processed', 'Multiselect', 'on');
if iscell(file_list) == 0
file_list={file_list};
end
for i = 1:length(file_list)
filename = file_list{i};
data_in = readtable([path_n filename]);
W=width(data_in)
figure
vNames = data_in.Properties.VariableNames;
for i =2:2:(W-1)
t = i
time = data_in(:,t)
i = i+1
d = i
data = data_in(:,d)
% then i need to ask user if they want to plot data
% of the specific name of the data being pulled from the table
% or delete it
plot(data.(1),time.(1),'DisplayName',vNames{d-1})
legend
hold on
end
end
for example
"would you like to plot 'Low_PressureValueY'" y/n
and the next one would be
"would you like to plot 'Pressure_DE_InletValueY'" y/n
for even numbers of i to w
If anyone could help me out it would be much appreciated,
i am trying to pull the names from a cell, the xlsx file is attatched,
Kind regards,
Brandon

回答 (1 件)

Jeff Miller
Jeff Miller 2021 年 6 月 16 日
how about:
fprintf('Would you like to plot %s ? (y/n)', vnames{d-1})

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by