[Scilab-users] Scilab Program

Dang, Christophe Christophe.Dang at sidel.com
Mon Apr 29 11:42:16 CEST 2013


Hello,

De la part de WoeiSoon Owi
Envoyé : lundi 29 avril 2013 03:51

> Hereby, I attached the algorithm and the Scilab program

A quick overview:

*****

I found three obvious errors:

You use the function cdfnormal(),
do you mean cdfnor() or is it a homemade function?

The endfunction is missing (but might be a copy-paste error?).

And there seems to be an exceeding "else" in the script.

*****

Now,

there are a few simple things you could do to make your code clearer,
which means easier to debug and maintain:

You feed the function with Muo and sigma,
but you don't use them.

there are useless lines that should be removed to make the code clearer:

n1 = n1 ; k1 = k1 ; L1 = L1

The calculation of ATSo and ATS1 could be in separate functions,
as the same formula is used twice.

The overall structure is weird:
you define a while loop that is intented to never execute
(the "normal" behaviour is break),

If the default values are k1, L1, n1, m1,
then you'd better write something like

while m1 >= n1
    <all your code that was inside the main while loop>
    ....
end

k = k1; L = L1; n = n1; ATS = m1;

So, I attached a script that is -- to me -- somewhat clearer.

It will probably not work as such,
as I don't know what you are computing
and I could not test it.

But you could use it as a basis to write clearer code
that be easier for you or anyone else to debug and maintain.

Hope this helps.

-- 
Christophe Dang Ngoc Chan
Mechanical calculation engineer

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.sci
Type: application/octet-stream
Size: 1233 bytes
Desc: foo.sci
URL: <https://lists.scilab.org/pipermail/users/attachments/20130429/09483139/attachment.obj>


More information about the users mailing list