Hi, I have written that equations but I got an error at the end... A=0.05; rho=1.225; t=0.001; v=5; Cu(1)=1.3; Cl(1)=0.34; u(1)=0; a(1)=0; i=2:1000; u(i)=u(1)+du(i); da(i)=ds(i)*360/0.628; ds(i)=du(i)*t; a(i)=da(i)+a(i-1); du(i)=F(i-1)*0.001/0.05; F(i-1)=(F1(i-1)-F2(i-1))*cos(a(i-1)); F1(i-1)=0.5*1.225*Cu(i-1)*A(i-1)*(v-u(i-1))^2; F2(i-1)=0.5*1.225*Cl(i-1)*A(i-1)*(v+u(i-1))^2; A(i-1)=A*cos(a(i-1)); Cu=-0.0053*a(i-1)+1.3; Cl(1)=0.0053*(180+a(i-1)); ??? Undefined function or method 'du' for input arguments of type 'double'. Error in ==> Scientific at 10 u(i)=u(1)+du(i); thanks a lot...
:
Verschoben durch User
Line 10 is "u(i)=u(1)+du(i);" as you say. In the lines before you never define "du". How should Matlab know what to do with that variable? You must define it before you work with it.
ok thanks... i thought that it is a much complex problem... I have to correct all the sequence of the equations. I have to write also in the physical way for my anemometer simulation...
This Program shall work if you place line du(i)=F(i-1)*0.001/0.05; before line u(i)=u(1)+du(i);
A(1)=0.05; rho=1.225; t=0.01; v=5; u(1)=0; a(1)=0; C(1)=1.3; for i=2:1000 C(i-1)=0.82+0.48*cos(a(i-1)); A(i-1)=A(1)*cos(a(i-1)); F1(i-1)=0.5*1.225*C(i-1)*A(i-1)*(v-u(i-1))^2; F2(i-1)=0.5*1.225*C(i-1)*A(i-1)*(v+u(i-1))^2; F(i-1)=(F1(i-1)-F2(i-1))*cos(a(i-1)); du(i)=F(i-1)*0.001/0.05; u(i)=u(1)+du(i); ds(i)=du(i)*t; da(i)=ds(i)*2*pi/0.628; a(i)=da(i)+a(i-1); end i corrected the codes in that way...C(1)=1.3; does not make sense but I left it... the first line and the last one C(i-1)=0.82+0.48*cos(a(i-1)); .. a(i)=da(i)+a(i-1); depend on eachther. that is why i wrote if end loop. I dont get any fault but my problem is that I got the constant values for all variables in my Workspace. thanks a lot
for each variable I got this error The variable 'F2' appears to change size on every loop iteration (within a script). Consider preallocating for speed Explanation The size of the indicated variable or array appears to be changing with each loop iteration. Commonly, this message appears because an array is growing by assignment or concatenation. Growing an array by assignment or concatenation can be expensive. For large arrays, MATLAB must allocate a new block of memory and copy the older array contents to the new array as it makes each assignment. Programs that change the size of a variable in this way can spend most of their run time in this inefficient activity. There is also significant overhead in shrinking an array on each iteration or in changing the size of a variable on each iteration. In such cases, MATLAB must reallocate and copy the contents repeatedly. For scripts, M-Lint cannot determine whether the array was preallocated before the script was called. Depending on your use of scripts, you might want to enable or disable this message independently of the related message (with message ID AGROW) that applies to functions and class methods. Suggested Action Consider preallocating a variable or array before entering the loop by using zeros, ones, cell, or a similar function. Preallocating avoids the need for MATLAB to copy the data from one array to another inside the loop. For examples of code that do and do not preallocate an array, see “Preallocating Arrays” When an array grows by assigning past the end of the array or using concatenation, preallocation alone does not improve the performance. The code must use explicit indices also. Assigning to an array in a script that the caller of the script preallocated provides an opportunity to create bugs that are difficult to detect. If the script is called multiple times, these bugs are particularly difficult to detect. However, there are other uses of scripts where preallocating in this manner is necessary or even desirable. In this case, suppress the message for specific assignments or for the whole script, as described in “Suppressing M-Lint Indicators and Messages”. It might also be appropriate to suppress this message if any of the following is true: The loop code is searching for rare or exceptional events (especially if you do not expect it to find any). In this case, it can be reasonable to grow the array only as the loop code finds such events. The array is small and will always be small. In this case, the impact of recopying is also small. The array was preallocated, but in a way that M-Lint does not recognize. If you do not know the size of an array before the loop begins, preallocate it, and then shrink it, if necessary, after the loop completes.
bora bora schrieb: > for each variable I got this error > > The variable 'F2' appears to change size on every loop iteration (within > a script). Consider preallocating for speed This is not an error message, but a suggestion for speed increase. > Consider preallocating a variable or array before entering the loop by > using zeros, ones, cell, or a similar function. > ... > For examples of code that do and do not preallocate an array, see > “Preallocating Arrays” And, did you read this help item?
Yes I read. I looked at this links http://www.mathworks.de/support/solutions/en/data/1-18150/ http://www.mathworks.de/de/help/matlab/matlab_prog/techniques-for-improving-performance.html I tried to apply it also for my file like that: C=zeros(1000); A=zeros(1000); F1=zeros(1000); F2=zeros(1000); F=zeros(1000); du=zeros(1000); u=zeros(1000); ds=zeros(1000); da=zeros(1000); a=zeros(1000); However, I see now only matrixes and the first column is for C for example only 1.3 and the other all columns are zero. It didnt solve my problem I see again constant values but I have know matrix with zeros... I couldnt solve yet.
bora bora schrieb: > C=zeros(1000); > A=zeros(1000); > F1=zeros(1000); > F2=zeros(1000); > F=zeros(1000); > du=zeros(1000); > u=zeros(1000); > ds=zeros(1000); > da=zeros(1000); > a=zeros(1000); > I see now only matrixes Every Matlab command has its own help item. Its on you to use this help. From the help text of the "zeros" command: http://www.mathworks.com/help/matlab/ref/zeros.html: > B = zeros(n) returns an n-by-n matrix of zeros. An error > message appears if n is not a scalar. > > B = zeros(m,n) or B = zeros([m n]) returns an m-by-n matrix > of zeros. What do you think will "C=zeros(1000)" do?
Ok. it changes my C value to a matrix as it should be... it is ok... I have to check my algorith I think... because of the equations I cannot get variable values maybe.
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.