for loop, conditional operator

2 ビュー (過去 30 日間)
Kashfia Mahin
Kashfia Mahin 2019 年 8 月 16 日
編集済み: Kashfia Mahin 2019 年 8 月 19 日
for k=1:length(kinetic);
if (delta(j)<=kinetic(k)) && (j==k)
filling_degree_regionI(j,k)=1/(2*pi).*(pi*(abra)/180-((rh/R).*cosd(kappa-kinetic(k))./cosd(alpha).*sind(abra)./cosd(shai-kinetic(k))))
filling_degree_regionI_new(1,k)=filling_degree_regionI(j,k);
end
end
end
for i=1:length(filling_degree_regionI_new);
if filling_degree_regionI(i) > 0
new_filling_degree_regionI(i)=filling_degree_regionI(i);
end
end
Here, I have to calculate filling degree using delta and kinetics. Kinetics[1*13] are calculated using delta[1*13]=[0:10:180]. To calculate filling degree[1*13], delta should be less than equal to kinetics and length of delta and kinetics should be same. and also filling degree can't be zero. but there is some error showing there.
Undefined function or variable 'filling_degree_regionI_new'.
i can't figure it out how to solve it.

採用された回答

James Tursa
James Tursa 2019 年 8 月 16 日
編集済み: James Tursa 2019 年 8 月 16 日
You are creating the variable filling_degree_regionI_new inside a condition if statement. If the condition is never met, the variable filling_degree_regionI_new will not be created.
Maybe you could describe in words what variables you are starting with, what they contain, and what calculation you hope to do with them. We might be able to suggest a better way than what you are currently doing. E.g., what is the point of your double for-loops at the beginning if you don't take any action unless j==k? A single for-loop would suffice.
  1 件のコメント
Kashfia Mahin
Kashfia Mahin 2019 年 8 月 17 日
Thanks for your reply.
I have [1*13] values of delta which are arranged [-90:30:270]. I use delta arrays to calculate kinetic[1*13]. Now I have to calculate filling degree using delta and kinetics. different filling depends on the values of delta and kinetic. it would be like that- filling_degree_regionI(1) will be calculated using delta(1) and kinetic(1). for filling_degree_regionI(2), delta(2) and kinetic(2) are needed.
but there are two condition-
1) delta has to be less than equal to kinetics.
I wrote j==k because I used two loops. I am confused how to make algorithms.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by