help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variable and plot


From: Doug Stewart
Subject: Re: variable and plot
Date: Tue, 10 Apr 2018 10:12:51 -0400



On Tue, Apr 10, 2018 at 4:35 AM, Patrick Dupre <address@hidden> wrote:
Hello,

I am starting with octave.
2 questions.
1)
If I type this function under octave, it is fine,
but when it is in a file and that I make
source "myfile.m"
I get an error
error: 't' undefined near line 1 column 8

function y = f_LG (x, t, wD, g)
  tt = t ./ wD;
  y = exp (-tt .* tt) ./ ((x .- t).**2 .+ g .* g);
endfunction


1)  you should name the file the same name as the function name
2) since you didn't then you can do:
     q=myfile( xvalues, tvalues, wD value, g value)
in other words you must send some numbers to the function


 
2)
I have a function
function y = Voigt (x, wD, g)
  y = quad (@(t) w (x, t, wD, g), -10,10);
endfunction

which seems to work

Voigt (0, 5, 0.1)
ans =  30.719

but, I cannot plot it

x=-10:0.1:10;
 plot (x, Voigt (x, 4,0.1));
This gives me a constant value.

Thank for your help.

===========================================================================
 Patrick DUPRÉ                                 | | email: address@hidden
 Laboratoire de Physico-Chimie de l'Atmosphère | |
 Université du Littoral-Côte d'Opale           | |
 Tel.  (33)-(0)3 28 23 76 12                   | | Fax: 03 28 65 82 44
 189A, avenue Maurice Schumann                 | | 59140 Dunkerque, France
===========================================================================





--
DASCertificate for 206392


reply via email to

[Prev in Thread] Current Thread [Next in Thread]