[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
creating a plot of a self-defined function
From: |
Erik Leunissen |
Subject: |
creating a plot of a self-defined function |
Date: |
Sun, 16 Feb 2014 23:57:12 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 |
Hi all,
As a newcomer to octave, I've been experimenting with functions and
plots, but I fail to create a plot of a self-defined function. Here is
what I do:
In a function file myfunc.m I've got:
function C = myfunc (x,t)
global M A v Dx k;
C=M/A*exp(-(x-v*t)^2/(4*Dx*t)-k*t)/(2*sqrt(pi*Dx*t));
endfunction
In another file "parameters.m", I've got default values for the
variables M, A, v Dx and k.
In octave at the command line, I first check whether the function myfunc
works:
octave:1> source parameters.m
octave:2> myfunc(2,3)
ans = 5.2180
OK. Next creating the plot, analoguous to section 15.2.2.2 of the manual:
octave:3> C = @(x,t) myfunc (x,t);
octave:4> ezmesh (C, [-5, 10, 0, 10]);
warning: matrix singular to machine precision, rcond = 0
warning: matrix singular to machine precision, rcond = 0
octave:5>
This results in a separate window with a 3D grid popping up, but it
contains no plot.
I'm familiar with each of the words in the warning message (except for
the phrase "rcond = 0"). But the sentence as a whole doesn't mean
anything to me yet.
Could somebody please provide me with some directions to help me make
progress with this 3D plot?
Thanks in advance,
Erik Leunissen.
- creating a plot of a self-defined function,
Erik Leunissen <=