wierd octave behaviour

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

wierd octave behaviour

GillouStyle
Hello there,

 I am using Octave 3.0.1 on Mac OS X 10.5. It works fine, however It
is giving me a hard time with one special calculation.
I get a "syntax error    >>>" endfunction^ " 99% of the time.

About 5 minutes again, it worked, (see screen) but it does not work
anymore. I am pasting my .m file below

close all
clear*

function Ia=f(Suns,Va,TaC)
k=1.38e-23;
q=1.60e-19;
n=1.2;
Vg=1.12;
Ns=36;
T1=273+25;
Voc_T1=21.06/Ns;
Isc_T1=3.80;
T2=273+75;
Voc_T2=17.05/Ns;
Isc_T2=3.92;
TaK=273+TaC;
K0=(Isc_T2-Isc_T1)/(T2-T1);
IL_T1=Isc_T1*Suns;
IL=IL_T1+K0*(TaK-T1);
I0_T1=Isc_T1/(exp(q*Voc_T1/(n*k*T1))-1);
I0=I0_T1*(TaK/T1).^(3/n).*exp(-q*Vg/(n*k).*((1./TaK)-(1/T1)));
Xv=I0_T1*q/(n*k*T1)*exp(q*Voc_T1/(n*k*T1));
dVdI_Voc=-1.15/Ns/2;
Rs=-dVdI_Voc-1/Xv;
Vt_Ta=k*TaK/q;
Vc=Va/Ns;
Ia=zeros(1,length(Va));
for j=1:5
Ia=Ia-(IL-Ia-I0.*(exp((Vc+Ia.*Rs)./Vt_Ta)-1))./(-1-(I0.*(exp((Vc+Ia.*Rs)./Vt_Ta)-1)).*Rs./Vt_Ta);
endfor
end function

voltage=f(0,25);
onesun=f(1,voltage,25)
halfsun=f(.5,voltage,25);
quartersun=f(.25,voltage,25);
plot(voltage,onesun,voltage,halfsun,voltage,quartersun)

grid on
axis ([0 20 0 4])




If you have any idea.. that would really make peace between me and Octave.

_______________________________________________
Help-octave mailing list
[hidden email]
https://www.cae.wisc.edu/mailman/listinfo/help-octave

ivcurves.pdf (19K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: wierd octave behaviour

Michael Grossbach
cyber gilles wrote:
> Hello there,
>
>  I am using Octave 3.0.1 on Mac OS X 10.5. It works fine, however It
> is giving me a hard time with one special calculation.
> I get a "syntax error    >>>" endfunction^ " 99% of the time.


> end function
>


You are getting this error because it should read

endfunction

and not

end function

HTH,

Michael
_______________________________________________
Help-octave mailing list
[hidden email]
https://www.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: wierd octave behaviour

GillouStyle
Thank you Michael for the quick response.

You are right.. I changed it BUT I get a new error :

error: `TaC' undefined near line 16 column 9
error: evaluating binary operator `+' near line 16, column 8
error: evaluating assignment expression near line 16, column 4
error: called from `f'
error: evaluating assignment expression near line 33, column 8
error: near line 33 of file `/Users/GS/simpsons_normal.m'

I do not understand why it says TaC is undefined. I thought that was
the whole point of having a function?

On Mon, Jul 21, 2008 at 11:49 AM, Michael Grossbach
<[hidden email]> wrote:

> cyber gilles wrote:
>>
>> Hello there,
>>
>>  I am using Octave 3.0.1 on Mac OS X 10.5. It works fine, however It
>> is giving me a hard time with one special calculation.
>> I get a "syntax error    >>>" endfunction^ " 99% of the time.
>
>
>> end function
>>
>
>
> You are getting this error because it should read
>
> endfunction
>
> and not
>
> end function
>
> HTH,
>
> Michael
>
_______________________________________________
Help-octave mailing list
[hidden email]
https://www.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: wierd octave behaviour

Miroslaw Kwasniak
In reply to this post by GillouStyle
On Mon, Jul 21, 2008 at 11:29:48AM -0400, cyber gilles wrote:
> end function

  ^^^^^^^^^^^^^
  endfunction
 
_______________________________________________
Help-octave mailing list
[hidden email]
https://www.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: wierd octave behaviour

Miroslaw Kwasniak
In reply to this post by GillouStyle
On Mon, Jul 21, 2008 at 11:59:35AM -0400, cyber gilles wrote:

> Thank you Michael for the quick response.
>
> You are right.. I changed it BUT I get a new error :
>
> error: `TaC' undefined near line 16 column 9
> error: evaluating binary operator `+' near line 16, column 8
> error: evaluating assignment expression near line 16, column 4
> error: called from `f'
> error: evaluating assignment expression near line 33, column 8
> error: near line 33 of file `/Users/GS/simpsons_normal.m'
>
> I do not understand why it says TaC is undefined. I thought that was
> the whole point of having a function?

voltage=f(0,25);
              ^^^  third parameter is missing :(
_______________________________________________
Help-octave mailing list
[hidden email]
https://www.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: wierd octave behaviour

wim van hoydonck
In reply to this post by GillouStyle
On Mon, Jul 21, 2008 at 5:59 PM, cyber gilles <[hidden email]> wrote:
> You are right.. I changed it BUT I get a new error :
>
> error: `TaC' undefined near line 16 column 9
>
> I do not understand why it says TaC is undefined. I thought that was
> the whole point of having a function?
>

That is because the first time you call your function (on line 16),
TaC _is_ undefined:

> voltage=f(0,25);

misses the third (TaC) argument.

Either make it:
voltage = f(0,25,0);

or make sure the function can handle a variable number of input arguments.
_______________________________________________
Help-octave mailing list
[hidden email]
https://www.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: wierd octave behaviour

GillouStyle
Oh my bad, (that's what happens when you can't sleep at night)

it was supposed to be

voltage=linspace(0,25);

and not f(0,25)

It is working perfectly now.

Thank you very much.

On Mon, Jul 21, 2008 at 3:25 PM, wim van hoydonck
<[hidden email]> wrote:

> On Mon, Jul 21, 2008 at 5:59 PM, cyber gilles <[hidden email]> wrote:
>> You are right.. I changed it BUT I get a new error :
>>
>> error: `TaC' undefined near line 16 column 9
>>
>> I do not understand why it says TaC is undefined. I thought that was
>> the whole point of having a function?
>>
>
> That is because the first time you call your function (on line 16),
> TaC _is_ undefined:
>
>> voltage=f(0,25);
>
> misses the third (TaC) argument.
>
> Either make it:
> voltage = f(0,25,0);
>
> or make sure the function can handle a variable number of input arguments.
>
_______________________________________________
Help-octave mailing list
[hidden email]
https://www.cae.wisc.edu/mailman/listinfo/help-octave