>Here is that file with a problem I do not understand.
># dfac.m 21/2/2019 double factorial
> for i=n:-2:2,f=f*i;,endfor
You should tell us what is the problem and what you do not understand.
If you run it and get an unexpected result or an error, you should copy
and paste what you see on the command window (text, no image) and tell
us what you expected instead.
Francesco Potortì (ricercatore) Voice: +39.050.621.3058
ISTI - Area della ricerca CNR Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa Skype: wnlabisti
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it
On 21 Feb 2019 10:16:03 +0100 "Robert Setif" wrote:
> Here is that file with a problem I do not understand.
> # dfac.m 21/2/2019 double factorial
> function r=dfac(n)
> if (n=0)
> elseif (mod(n,2)=0)
> for i=n:-2:2,f=f*i;,endfor
> for i=1:2:n,f=f*i;,endfor
I am not sure what the problem is you see. But you probably want to use the comparison operator "==" instead of the assignment operator "=" in the conditions.
I think I answered the same questions in the response to your previous message. Please read below.
If you still have more specific questions, please do ask them.
Am 23. Februar 2019 um 09:17 Uhr schrieb "Robert Setif":
> Hello! and thank you.
> I write in English and you also answer to me in Englih:
> I understand English but unfortunately speak it.
> Here is the file "dfac.m" joined and what Octave answer:
> " >> dfac1
> warning: function name 'dfac' does not agree with function
> filename 'C:\Users\Robert\NEWPROG\Octave\dfac.m'
> error: 'n' undefined near line 5 column 6
> error: called from
> dfac1 at line 5 column 2 "
> but dfac(10)-> 3840 dfac(11)-> 10395 Ok
> I can't program dfac([1:10]).
> Unfortunately I am not able to vectorize that function.
> Would you correct my file, please?
> That is not urgent. I am patient.
> Thank you very much and best regards.
> Robert SETIF France
> [hidden email][mailto:[hidden email]]
> Le ven. 22 févr. 2019 à 18:33, "Markus Mützel" <[hidden email][mailto:[hidden email]]> a écrit :
> Please keep the mailing > list in CC, so others who might be able to help can answer as well.
> Am 22. Februar 2019 um 08:47 Uhr schrieb "Robert Setif":
> > Hello !
> > Thank you for your very fast answer. You find an error: "=" au lieu de "==".
> > Je continue en français. Maintenant c'est ok, presque. Voici le message de Octave:
> > "error: 'n' undefined near line 4 column 6
> > error: called from
> > dfac at line 4 column 2.
> > mais dfac(10) -> 3840
> > Voici 2 questions:
> > 1. Cette erreur n'empêche pas de fonctionner. Mais elle est signalée dans presque tous mes programmes. Pourquoi "'n' undefined" et comment y remédier ?
> Your function "dfac" has one input argument "n". You probably see this error because you called the the function without input argument. I haven't tried but something like "dfac(5)" should not throw this error.
> > 2. Comment faire pour que dfac([1:10]) fonctionne ? Il ya sans doute une autre façon de le faire, mais laquelle ?
> Each line of your function must work with "n" as a vector for this to work.
> E.g. instead of writing:
> if (n==0)
> you would write:
> r = zeros (size (n)); % initialize r to the same size as n
> r(n==0) = 1; % only set those elements in "r" that correspond to n==0
> And appropriately for the other conditional branches.
> > Thank you very much and best regards.