MATLAB Answers

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

1 view (last 30 days)
Brandon Tuttle
Brandon Tuttle on 15 Jun 2021
Answered: Jeff Miller on 16 Jun 2021
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

Tags

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!