Evaluating Array Values with Different Functions Based On Array Index Value
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Nicholas
am 15 Sep. 2015
Beantwortet: Jae Song
am 15 Sep. 2015
I am working on a thin column buckling problem. I have a 1x40 matrix of values (SR) that correspond to a key parameter. If this value is less than 10, Pcr (my end goal) is some constant value. If this value is between 10 and 100, Pcr = SR^2. If SR > 100, Pcr = SR^3. I have the following code
if true
i=1
for i=1:1:40
if SR(i)>0 && SR(i)<=10
Pcr=80,000;
elseif SR(i)>=10 && SR(i)<=100
Pcr=SR.^2
elseif SR(i)>=100
Pcr=SR.^3
end
end
end
My desired result is a 1x40 matrix of Pcr with each value as a function of its respective equation.
0 Kommentare
Akzeptierte Antwort
Jae Song
am 15 Sep. 2015
You can put an index for the Pcr variable ( and SR variable as well). Please try the following code.
for i=1:1:40
if SR(i)>0 && SR(i)<10
Pcr(i)=80000;
elseif SR(i)>=10 && SR(i)<100
Pcr(i)=SR(i).^2;
elseif SR(i)>=100
Pcr(i)=SR(i).^3;
end
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Financial Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!