I keep getting undefined function when preallocating
Show older comments
Hi,
I am trying to create a for loop wherein the temperature that is outputted is then subbed back in, I have preallocated but i get the error undefined function '(index)' when it comes to the line: S1QAmb(index)=zeros(size(index)) %surface 1, ambient load. Since the size of the array will change with the size of the index, I did not think the (index) needed to be defined. Also, if any other mistakes are spotted, please do let me know. Thank you.
My script is below:
U=1
S1=1.7*1.2 %Surface area of surface 1
S2= 1.7*1.2 %Surface 2 area
S3= 1.7*1.2 %surface 3 area
S4= 1.7*1.2 %surface 4 area
S5= 1.7*1.2 %surface 5 area
S6= 1.7*1.2 %surface 6 area
S7= 1.7*1.2 %surface 7 area
S8= 1.7*1.2 %surface 8 area
S9= 1.7*1.2 %surface 9 area
S10= 1.7*1.2 %surface 10 area
Tout=5
ma=1
ca=2
DTM=1
deltat=1
%Prealloacate
S1QAmb(index)=zeros(size(index)) %surface 1, ambient load
S2QAmb(index)=zeros(size(index)) %surface 2, ambient load
S3QAmb(index)=zeros(size(index)) %surface 3, ambient load
S4QAmb(index)=zeros(size(index)) %surface 4, ambient load
S5QAmb(index)=zeros(size(index)) %surface 5, ambient load
S6QAmb(index)=zeros(size(index)) %surface 6, ambient load
S7QAmb(index)=zeros(size(index)) %surface 7, ambient load
S8QAmb(index)=zeros(size(index)) %surface 8, ambient load
S9QAmb(index)=zeros(size(index)) %surface 9, ambient load
S10QAmb(index)=zeros(size(index)) %surface 10, ambient load
QAmb_Total(index)=zeros(size(index)) %Total Ambient Load
deltaTin(index)=zeros(size(index))
Tin(index)=zeros(size(index))
for index=(1:30)
if (index)==1
Tin(index)=20
else
Tin(index)=Tin(index-1)+deltaTin(index)
end
%Ambient Load
S1QAmb(index)=S1*U*(Tout-+Tin(index)) %surface 1, ambient load
S2QAmb(index)=S2*U*(Tout-+Tin(index)) %surface 2, ambient load
S3QAmb(index)=S3*U*(Tout-+Tin(index)) %surface 3, ambient load
S4QAmb(index)=S4*U*(Tout-+Tin(index)) %surface 4, ambient load
S5QAmb(index)=S5*U*(Tout-+Tin(index)) %surface 5, ambient load
S6QAmb(index)=S6*U*(Tout-+Tin(index)) %surface 6, ambient load
S7QAmb(index)=S7*U*(Tout-+Tin(index)) %surface 7, ambient load
S8QAmb(index)=S8*U*(Tout-+Tin(index)) %surface 8, ambient load
S9QAmb(index)=S9*U*(Tout-+Tin(index)) %surface 9, ambient load
S10QAmb(index)=S10*U*(Tout-+Tin(index)) %surface 10, ambient load
%Total Ambient Load in Array Form
QAmb_Total(index)=S1QAmb(index)+S2QAmb(index)+S3QAmb(index)+S4QAmb(index)+S5QAmb(index)+S6Amb(index)+S7QAmb(index)+S8QAmb(index)+S9QAmb(index)+S10QAmb(index)
%changein air cabin temperature where deltat is timestep
deltaTin(index)=(QAmb_Total(index)/((ma*ca)+DTM))*(deltat)
%New car cabin temperature
Tin(index)=Tin(index-1)+deltaTin(index)
end
Accepted Answer
More Answers (0)
Categories
Find more on Number Theory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!