フィルターのクリア

How to store the results of a function using for-loop

1 回表示 (過去 30 日間)
AliAlemana
AliAlemana 2018 年 12 月 11 日
コメント済み: Matt J 2018 年 12 月 11 日
Hello everyone, I am pretty sure my problem is super simple but it is driving me crazy.
I have a temperature T(x,y,z) which I want to calculate using a formula which includes P (the power). Now I want to calculate the temperature for 3 different P, therefore I used a for-loop but since T is a 3D-matrix, I always get errors since I am not sure how to exactly write the loop. Something like this (the formula is not real, it is just to show you what I mean):
[x,y,z] = deal(linspace(0,10));
P=[100,150,200];
for i=1:3
T(i,:)=P(i)/(x.*y.*z);
end
The result I would like is T(1), T(2) and T(3) stored in the workspace calculated with the different P.
Thanks a lot, sorry for the weird formula.

採用された回答

Matt J
Matt J 2018 年 12 月 11 日
T=cell(1,3);
for i=1:3
T{i}=P(i)/(x.*y.*z);
end
  2 件のコメント
AliAlemana
AliAlemana 2018 年 12 月 11 日
Thanks Matt!
Matt J
Matt J 2018 年 12 月 11 日
You're welcome, but please Accept-click the answer to certify that it solved the issue for you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by