[Scilab-users] unable to find my mistake in the function

Sachverständigenbüro Niedermaier Holger fachbueroniedermaier at bayern-mail.de
Wed Jun 7 08:03:36 CEST 2017


Hello Mike, 
thanks and yes you are right.
First it makes no sense to define t(1) three times and schritte could be non integer in general. 
Because schrittweite is selected as 1/n times of (bis-von) it causes no problem. But it’s not really good programming, I agree. 
Despite from that I can not realize why y(i+1) and t(i+n) can be used but Energie(n) causes an error? Non of them defined previously. 
I’m obviously far from being an expert (to be honest I’m a newcomer using such powerful tool), so please accept my excuse if the question seems to be „stupide“ to you. 
t() grows depending on schritte but the size is not previously defined.
Holger 
> Am 06.06.2017 um 14:53 schrieb Michael J McCann <mjmccann at ieee.org>:
> 
> Looks   a bit strange to me : in loop n=1:3,  t(1) is defined three times (may be OK)
> but schritte could be  non integer so a bit odd for an index into an array.
> Is the t() array being grown (size not previously defined)?
> Mike.
> 
> On 06/06/2017 08:27, Sachverständigenbüro Niedermaier Holger wrote:
>> Dear all, 
>> may anybody be able to explain why I get the error message "invalid index in line 12“ by running the following function?
>> 
>> function [Wert]=Berechnungsfunktion(von, bis, schrittweite, y0, y2, t0, t2)
>>     for n=1:3
>>         t(1)=t0;
>>         y(1,n)=y0;
>>         schritte=(bis-von)/schrittweite;
>>        for i=1:schritte
>>             t(i+1)=t(i)+schrittweite;
>>             y(i+1,n)=10^(log10(y0*Faktor(n))+log10(y2/y0)/log10(t2/t0)*log10(t(i+1)/t0))
>>        end
>>         disp(n)
>>         for i=1:schritte
>>             Energie(n)=Energie(n)+y(i)*y(i)*schrittweite*10^(-3);
>>         end
>>         disp(Energie(n))
>>      end
>>     //disp("1 Polig",Energie(3),"2 Polig", Energie(1),"3 Polig", Energie(2))
>>     //Wert=[Energie];
>> endfunction
>> I myself be to blind to find my mistake
>> Thanks a lot
>> Holger
>> 
>> 
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org <mailto:users at lists.scilab.org>
>> http://lists.scilab.org/mailman/listinfo/users <http://lists.scilab.org/mailman/listinfo/users>
> 
> -- 
> Dr.M.J.McCann,MJMcCann-Consulting
> 
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170607/e6b2858f/attachment.htm>


More information about the users mailing list