how to put for loop value into a vector

조회 수: 1 (최근 30일)
John Daniels
John Daniels 2022년 4월 24일
편집: VBBV 2022년 8월 9일
for x=0.168:0.168:1.68
if x>=0.03 && x<=0.06
h=1.437*x^(-0.279)
elseif x>=0.07 && x<=0.83
h=5.313*x^(-0.121)
else x>=0.85 && x<=1.68
end
how to put h vaules into vector after the loop

답변 (1개)

VBBV
VBBV 2022년 4월 24일
편집: VBBV 2022년 8월 9일
k = 0.168:0.168:1.68 ;
for x=1:length(k)
if k(x)>=0.03 && k(x)<=0.06
h(x)=1.437*k(x)^(-0.279);
elseif k(x)>=0.07 && k(x)<=0.83
h(x)=5.313*k(x)^(-0.121);
end
end
h
h = 1×4
6.5929 6.0625 5.7723 5.5748
You can try like this

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by