Posted on:

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(i1)=F(i1)*t/0.05; My question is F(i1) is result of the if elseif end loop below. How can I define it before? I wrote the equations F(i1)=F1(i1)F2(i1) and F(i1)=F4(i1)F3(i1) 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(i1) 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(i1)=0.82+0.48*cos(a(i1)); C2(i1)=0.82+0.48*cos(a(i1)+pi); A(i)=abs(A(1)*cos(a(i1))); F1(i1)=0.5*1.225*C1(i1)*A(i1)*(vu(i1))^2*abs(cos(a(i1))); F2(i1)=0.5*1.225*C2(i1)*A(i1)*(v+u(i1))^2*abs(cos(a(i1))); F3(i1)=0.5*1.225*C1(i1)*A(i1)*(v+u(i1))^2*abs(cos(a(i1))); F4(i1)=0.5*1.225*C2(i1)*A(i1)*(vu(i1))^2*abs(cos(a(i1))); n=0:100; if a(i1)>=(2*pi*n+(3*pi/2)) & a(i1)<(2*pi*n+(2*pi))  a(i1)>=(2*pi*n+0) & a(i1)<(2*pi*n+(pi/2)) F(i1)=F1(i1)F2(i1) elseif a(i1)>=(2*pi*n+(pi/2)) & a(i1)<(2*pi*n+(3*pi/2)) F(i1)=F4(i1)F3(i1) end du(i1)=F(i1)*t/0.05; ds(i1)=(u(i1)+du(i1))*t; da(i1)=ds(i1)*2*pi/0.628; %to write 'ds' in radian as angle u(i)=u(i1)+du(i1); a(i)=da(i1)+a(i1); end
:
Moved by Admin
Posted on:

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

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...
Posted on:

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

thank you for your answer but I do not understand all what you mean. a(i1) 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(i1)=F1(i1)F2(i1) 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(i1)=F4(i1)F3(i1) 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
Posted on:

You compare a scalar a(i1) 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.
Posted on:

You compare a scalar a(i1) 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(i1)=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 ???
Posted on:

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

a(i1)>=(2*pi*n+0) => false a(i1)<(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?
Posted on:

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

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.
Posted on:

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