calling a callback function from script
조회 수: 3 (최근 30일)
이전 댓글 표시
vishnuvardhan naidu tanga
2020년 2월 7일
편집: JESUS DAVID ARIZA ROYETH
2020년 2월 7일
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
댓글 수: 1
Stephen23
2020년 2월 7일
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
2020년 2월 7일
편집: JESUS DAVID ARIZA ROYETH
2020년 2월 7일
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
댓글 수: 3
Steven Lord
2020년 2월 7일
There's no such thing as element 0 in an array in MATLAB. The first element of p is p(1) not p(0).
In this case there's no need to create p inside the for loop.
p = 1 + b*(0:L);
I don't know whether your XSteam function can accept a vector of values as its second input. If it can (and returns a vector the same size as that second input, where each element of the output is the result of operating on the corresponding element of that second input) you could eliminate the loop altogether.
y = XSteam('rho_pT', 0:L, T);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!