I am stuck on trying to write the output of a for loop into a vector. The issue is that once it goes through the equation, it stops and spits out this error: "Subscript indices must either be real positive integers or logicals."
I've looked into what this error is and I've checked my code. There are no negative integers being output, nor any zeros. The for-loop, function and the fzero command are all good, if I comment out MW4p(y4,:) = MW4
I get all of my answers on the command window. I just can't put them into an array.
for y4 = linspace(1.4,1.67,100)
x0 = 12; %Starting Point
fun = @(MW4) (y4.*MW1.*T3)./(y1.*MW4.*T2) - ...
(((1+((y4+1)./(y4-1)).*p5p2).*((2.*y4)./(y4-1))) ./ ((1+...
((y1+1)./(y1-1)).*p5p2).*((2.*y1)./(y1-1)))) .* (((2./(y1-1))...
./ (2./(y4-1))).^2);
MW4 = fzero(fun,x0)
MW4p(y4,:) = MW4
end
where
y1 = 1.67;
MW1 = 39.55;
T3 = 250; %k
T2 = 700; %k
p5p2 = 2.307; %Determined from T5 desired
MW4p = ones(1,100);
In earlier attempts, I've tried MW4p(y4) = MW4
which had this error: "Attempted to access MW4p(1.4); index must be a
positive integer or logical." So I added a colon. Putting this command outside of the for-loop simply had it access the last value of the loop and return the same error.