Clear Filters
Clear Filters

i have made a code which finds a specific value 'no' from the excel sheet but it does the job one by one. i want to automate it so it gives all values with 'no' at once.

1 view (last 30 days)
this is the code i'm using.
data = readtable('FINALconvergencecheck_ksst.xlsx');
data.Properties.VariableNames(1) = "an6cd";
data.Properties.VariableNames(3) = "an6cl";
data.Properties.VariableNames(5) = "an6cm";
data.Properties.VariableNames(7) = "ap0cd";
data.Properties.VariableNames(9) = "ap0cl";
data.Properties.VariableNames(11) = "ap0cm";
data.Properties.VariableNames(13) = "ap3cd";
data.Properties.VariableNames(15) = "ap3cl";
data.Properties.VariableNames(17) = "ap3cm";
data.Properties.VariableNames(19) = "ap7cd";
data.Properties.VariableNames(21) = "ap7cl";
data.Properties.VariableNames(23) = "ap7cm";
data.Properties.VariableNames(25) = "ap10cd";
data.Properties.VariableNames(27) = "ap10cl";
data.Properties.VariableNames(29) = "ap10cm";
data.Properties.VariableNames(31) = "ap12cd";
data.Properties.VariableNames(33) = "ap12cl";
data.Properties.VariableNames(35) = "ap12cm";
data.Properties.VariableNames(37) = "ap14cd";
data.Properties.VariableNames(39) = "ap14cl";
data.Properties.VariableNames(41) = "ap14cm";
data.Properties.VariableNames(43) = "ap15cd";
data.Properties.VariableNames(45) = "ap15cl";
data.Properties.VariableNames(47) = "ap15cm";
data.Properties.VariableNames(49) = "ap17cd";
data.Properties.VariableNames(51) = "ap17cl";
data.Properties.VariableNames(53) = "ap17cm";
data.Properties.VariableNames(2) = "an6cd_r";
data.Properties.VariableNames(4) = "an6cl_r";
data.Properties.VariableNames(6) = "an6cm_r";
data.Properties.VariableNames(8) = "ap0cd_r";
data.Properties.VariableNames(10) = "ap0cl_r";
data.Properties.VariableNames(12) = "ap0cm_r";
data.Properties.VariableNames(14) = "ap3cd_r";
data.Properties.VariableNames(16) = "ap3cl_r";
data.Properties.VariableNames(18) = "ap3cm_r";
data.Properties.VariableNames(20) = "ap7cd_r";
data.Properties.VariableNames(22) = "ap7cl_r";
data.Properties.VariableNames(24) = "ap7cm_r";
data.Properties.VariableNames(26) = "ap10cd_r";
data.Properties.VariableNames(28) = "ap10cl_r";
data.Properties.VariableNames(30) = "ap10cm_r";
data.Properties.VariableNames(32) = "ap12cd_r";
data.Properties.VariableNames(34) = "ap12cl_r";
data.Properties.VariableNames(36) = "ap12cm_r";
data.Properties.VariableNames(38) = "ap14cd_r";
data.Properties.VariableNames(40) = "ap14cl_r";
data.Properties.VariableNames(42) = "ap14cm_r";
data.Properties.VariableNames(44) = "ap15cd_r";
data.Properties.VariableNames(46) = "ap15cl_r";
data.Properties.VariableNames(48) = "ap15cm_r";
data.Properties.VariableNames(50) = "ap17cd_r";
data.Properties.VariableNames(52) = "ap17cl_r";
data.Properties.VariableNames(54) = "ap17cm_r";
display = find(data.ap10cl_r=="no");
k=display;
k1=string(k);
switch k1
case "yes"
disp('convereged')
case "no"
disp('not convereged')
end
here, i have to change the coulum again and again. i want to automate it in a way that it gives all the values where 'no' is at once.
kindly help.

Answers (1)

Walter Roberson
Walter Roberson on 17 Nov 2023
display = find(data.ap10cl_r=="no");
The output in display will be a column vector of numeric row indices.
string() of that would be a string() array with the indices converted to displayable characters, such as
15
23
converted into
"15"
"23"
switch on these values will never match "yes" or "no"
Are you trying to display a list of row numbers that did not converge, and a list of row numbers that did converge? Did you want a column of output that has one entry per row and is more or less just an expansion of the current "no" and 'yes' entries to be more verbose?
  3 Comments
VBBV
VBBV on 2 Jun 2024
Edited: VBBV on 2 Jun 2024
Val = data.ap10cl_r(display)

You can use the indices vector to find out all the values corresponding to "no" as above.

Sign in to comment.

Tags

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!