Have multiple function output in a single array

Hello,
I have a function with 3 inputs and 1 output that I use within my code : "refpropm('h','T',T2+273.15,'Q',1,'R32')" T2 in one of the input parameters is a 1x45 double and what I want to get as the output is a single 1x45 double. I tried things like:
data = [ ] ; for T=T2 ; dat=refpropm('S','T',T+273.15,'Q',1,'R32')/1000 ; s2 = [data, dat] ; end
or
h2 = zeros(1,length(T2)) for i=1:length(T2) dat=refpropm('h','T',T2+273.15,'Q',1,'R32')/1000 h2(i)=dat end
But no good. Most of the time I end up with multiple 1x1's that overwrite the previous output finally keeping the last output. I'd really appreciate if someone could waste some of their time and help me out.
Respectfully, Hakan.

 採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 9 月 26 日
編集済み: Andrei Bobrov 2012 年 9 月 26 日

0 投票

data = [ ] ;
for T = T2 ;
data = [data, refpropm('S','T',T+273.15,'Q',1,'R32')/1000 ] ;
end
or
h2 = zeros(1,length(T2))
for ii=1:length(T2)
h2(ii)=refpropm('h','T',T2(ii)+273.15,'Q',1,'R32')/1000
end
or
data = arrayfun(@(t)refpropm('h','T',t+273.15,'Q',1,'R32')/1000,T2);

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by