# make a matrix of values from questions from another matrix

2 views (last 30 days)
Joseph Catanese on 27 Oct 2021
Edited: Joseph Catanese on 27 Oct 2021
I am trying to get a matix that has a list of values such as [1,2,1,2] and this matrix is from a set of questions that are asked based on another matrix i.e. [1,0,1,0]. i currenty have this.
qo = 2*[1,0,1,0]; %Load Magnitude
set(0, 'DefaultUIControlFontSize', 20);
%%
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
LT1 = 1;
LT2 = 1;
LT3 = 1;
LT4 = 1;
% Section 1
if qo(1) ~= 0
'Linear ramp up','Linear ramp down',...
'Half sinusoid','Half cosine',...
'Gradual point load of section of segment',...
'Section of segment Load',...
'Constant load with a segment of 0',...
'Trapezoidal distribution');
end
% Section 2
if qo(2) ~= 0
'Linear ramp up','Linear ramp down',...
'Half sinusoid','Half cosine',...
'Gradual point load of section of segment',...
'Section of segment Load',...
'Constant load with a segment of 0',...
'Trapezoidal distribution');
end
% Section 3
if qo(3) ~= 0
'Linear ramp up','Linear ramp down',...
'Half sinusoid','Half cosine',...
'Gradual point load of section of segment',...
'Section of segment Load',...
'Constant load with a segment of 0',...
'Trapezoidal distribution');
end
% Section 4
if qo(4) ~= 0
'Linear ramp up','Linear ramp down',...
'Half sinusoid','Half cosine',...
'Gradual point load of section of segment',...
'Section of segment Load',...
'Constant load with a segment of 0',...
'Trapezoidal distribution');
end
i want to simplify the LoadType variable to be a metrix of however many values there are in qo such that if qo were [1,0,1,0,1] then it would only ask the questions for qo(1) , qo(3) , qo(5) and so on. so that the Load type would then be something like [2, 1, 3, 1, 4]. i think i can use a for loop but have no idea.

David Hill on 27 Oct 2021
qo = 2*[1,0,1,0];
set(0, 'DefaultUIControlFontSize', 20);
for k=find(qo)
'Linear ramp up','Linear ramp down',...
'Half sinusoid','Half cosine',...
'Gradual point load of section of segment',...
'Section of segment Load',...
'Constant load with a segment of 0',...
'Trapezoidal distribution');
end
Joseph Catanese on 27 Oct 2021
how would i set up a matrix that is of strings such that lt = ['constant', 'linear ramp up','constant','constant'] depending on what choices were selected

R2021b

### Community Treasure Hunt

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

Start Hunting!