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.

 采纳的回答

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 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by