help-octave
[Top][All Lists]
Advanced

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

Question about creating functions...


From: Del Ventruella
Subject: Question about creating functions...
Date: Thu, 7 Apr 2016 11:36:16 -0400

I'm new to Octave.  I learned Matlab many years ago, but two decades have passed.

My initial attempts at writing functions follows.

Can anyone give me some help with this file?

Any pointers on functions and their inputs?

I may want to use variables, as I do here, or I may want to use an array.

Thanks!
======================

#! C:\Octave\Octave-3.8.2\octave.bat -qf 
# a sample Octave program 
clc;

function theta =thetaval(x)
if (x < 0)
   theta = 0;
elsif (x > 0)
   theta = 1;
else
   theta = 0.50;
endif
endfunction

function delta = deltaval(a,x)
delta = (a*sqrt(3.14159))^-1 * 2.7^(-y^2 / a^2);
endfunction

theta = cellfun(@thetaval,3)
delta = cellfun(@deltaval,(2,5))

printf ("theta = %10.2e \n",theta);
printf ("delta = %10.4e \n",delta);
# printf ("Hello, world!\n"); 
pause;
ans = input ("Press Enter to End");


reply via email to

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