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 Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2012년 9월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by