Hi everyone, I have an error in that algorithm. Undefined function or method 'F' for input arguments of type 'double'. Error in ==> Untitled67 at 31 du(i-1)=F(i-1)*t/0.05; My question is F(i-1) is result of the if elseif end loop below. How can I define it before? I wrote the equations F(i-1)=F1(i-1)-F2(i-1) and F(i-1)=F4(i-1)-F3(i-1) also before the if elseif loop but it does not work ... and it is unlogic to write the results before (??)... However the simulation runs when I wrote before but it is not as I wanted. I have defined the equations and have two cases for the F(i-1) function which I wrote in the if elseif end loop... my algorithm is here : A(1)=0.005; t=0.01; v=5; u(1)=0; a(1)=0; for i=2:2000; C1(i-1)=0.82+0.48*cos(a(i-1)); C2(i-1)=0.82+0.48*cos(a(i-1)+pi); A(i)=abs(A(1)*cos(a(i-1))); F1(i-1)=0.5*1.225*C1(i-1)*A(i-1)*(v-u(i-1))^2*abs(cos(a(i-1))); F2(i-1)=0.5*1.225*C2(i-1)*A(i-1)*(v+u(i-1))^2*abs(cos(a(i-1))); F3(i-1)=0.5*1.225*C1(i-1)*A(i-1)*(v+u(i-1))^2*abs(cos(a(i-1))); F4(i-1)=0.5*1.225*C2(i-1)*A(i-1)*(v-u(i-1))^2*abs(cos(a(i-1))); n=0:100; if a(i-1)>=(2*pi*n+(3*pi/2)) & a(i-1)<(2*pi*n+(2*pi)) | a(i-1)>=(2*pi*n+0) & a(i-1)<(2*pi*n+(pi/2)) F(i-1)=F1(i-1)-F2(i-1) elseif a(i-1)>=(2*pi*n+(pi/2)) & a(i-1)<(2*pi*n+(3*pi/2)) F(i-1)=F4(i-1)-F3(i-1) end du(i-1)=F(i-1)*t/0.05; ds(i-1)=(u(i-1)+du(i-1))*t; da(i-1)=ds(i-1)*2*pi/0.628; %to write 'ds' in radian as angle u(i)=u(i-1)+du(i-1); a(i)=da(i-1)+a(i-1); end

:

If both cases are not true u get the error, because F(i-1) is not defined. U need a code which handles every single possible case, not only this one u think that is possible ;)

But there is only two ranges of the value a , between 90 and 270 degree and 270 - 360 and 0 - 90 degree which I have defined...

As i have said before: for i=2 a(i-1)>=(2*%pi*n+(3*%pi/2)) & a(i-1)<(2*%pi*n+(2*%pi)) | a(i-1)>=(2*%pi*n+0) & a(i-1)<(2*%pi*n+(%pi/2)) == 101 times false a(i-1)>=(2*%pi*n+(%pi/2)) & a(i-1)<(2*%pi*n+(3*%pi/2)) == 101 times false If both cases are not true u get the error, because F(i-1) is not defined. U need a code which handles every single possible case, not only this one u think that is possible ;)

thank you for your answer but I do not understand all what you mean. a(i-1) shows the angles in radian anyway we can talk now in degrees. a(1) is defined "0" as starting point. The degrees refers to the way of anemometer . When it turns once position "a" reaches the angle of 360 degree. However it turns several times. that is why I defined an n value to simulate for example in that case 100 times and wrote 2*pi*n before the angles. there are two possibilities. if a is in between 0 and 90 and 270 - 360 I defined an equation as: F(i-1)=F1(i-1)-F2(i-1) if a is in between 90 - 270 (right plane of a coordinate system when we consider the left side as 0 degree) the equation is : F(i-1)=F4(i-1)-F3(i-1) i is the number of calculation for example in my example 2000 times. I do not know until which degree I arrive. Can it happen that i:2000 and n until 100 should match. I do not think that it is the problem... I have a question for you: you have written when for i=1 n==101 times false.... I didnt understand it. thank you

You compare a scalar a(i-1) with a vector (2*%pi*n+(3*%pi/2)) because n has the size of 101. So the program compares a() with every single member of the vector. -> You get 101 times a false if the comparison is not true. That happen in your program when i = 2.

You compare a scalar a(i-1) with a vector (2*%pi*n+(3*%pi/2)) because n has the size of 101. So the program compares a() with every single member of the vector. -> You get 101 times a false if the comparison is not true. That happen in your program when i = 2. when i=2 the a(i-1)=a(1)=0 as defined at the beginning. then the program compares this 0 value with (2*pi*n+(3*pi/2)) and it is 270 degree and its periods. for example 270 + 360 = 630 degree the same point in my anemometer which turns. It makes this calculation 100 times to get every point.. for 270 + 720 and so on. I have a question. you have written when i=2. however it makes the same thing also when if=3 , 4 and so on ???

and the value of a(1)=0 when it is compared it is in the range that I defined with: a(i-1)>=(2*pi*n+0) & a(i-1)<(2*pi*n+(pi/2)) or I am wrong. I have written >= big and equal ? I wrote also in the previous message some explanations

a(i-1)>=(2*pi*n+0) => false a(i-1)<(2*pi*n+(pi/2)) => true but false & true = false. So it is allwayse false.... How many additional advices do you need to find your problem?

sry for n =0 a(i-1)>=(2*pi*n+0) => true a(i-1)<(2*pi*n+(pi/2)) => true so you get 1 time true and 100 false (n>0). 1 true & 100 false = false

ok that is why I asked you what you mean... I tried only with n=0. There is still error. I do not need anymore advice thanks.

it works without any n vector. without n=0 and without any n integer. my algorithm is correct only I have to define the correct cycle

Only registered users may reply in this topic.

Log in with Google account | Log in with Facebook account

**Please log in before posting. Registration is free and takes only a minute.****Existing account**

**Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!**

Log in with Google account | Log in with Facebook account

**No account?**Register here.