# calling a callback function from script

5 views (last 30 days)
hello everyone,
I am trying to calculate the steam table data using the XSteam.m script. I have written a callback loop to calculate the density of the steam at perticular temperature and pressure values. the function is as follows.
where a is the final pressure
When i am trying to run the script it gives an error as
Error using zeros
Maximum variable size allowed by the program is exceeded.
Error in Untitled2 (line 5)
y = zeros(1:((a-1)/b));
Please check the script and help me with it.
With regards.
a = 10;
b = 0.01;
T = 200;
y = zeros(1:((a-1)/b));
L = length(y);
for i = 0:L
p(i)= 1+b*i;
y(i) =XSteam('rho_pT',i,T);
end
Stephen23 on 7 Feb 2020
This code
zeros(1:((a-1)/b))
defines an array with size
zeros(1,2,3,4,5,6,7,8,9,10,11,...,900)
which would require so much memory that it can't even be calculated using double numeric class. Impressive, but unlikely to be very useful. Perhaps you meant:
zeros(1,((a-1)/b));
% ^ comma

JESUS DAVID ARIZA ROYETH on 7 Feb 2020
Edited: JESUS DAVID ARIZA ROYETH on 7 Feb 2020
is y = zeros(1,((a-1)/b)); you have ":" instead of a ","
a = 10;
b = 0.01;
T = 200;
y = zeros(1,((a-1)/b));
L = length(y);
for i = 1:L
p(i)= 1+b*i;
y(i) =XSteam('rho_pT',i,T);
end
no, the function can not give an vector output. It only gives scalar outputs, and when I try this
p = 1 + b*(0:L);
all the values are turn to zero and i have used p(1).