For Programmers: Free Programming Magazines  


Home > Archive > Matlab > November 2005 > how to define a variable









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to define a variable
plindaq

2005-11-30, 4:02 am

my m file:

function y=c3ffun(x)
y=2/sqrt(pi)*exp(-x.^2);
area=quad('c3ffun',0,1.5)

wrong information:
??? Input argument 'x' is undefined.

Error in ==> D:\MATLAB6p5\test\Main.m
On line 2 ==> y=2/sqrt(pi)*exp(-x.^2);

what can I do for it?
thanks a lot
kinor

2005-11-30, 4:02 am

looks like you call your function without an argument, then x is not defined..
this can happen if you try to test your function with the run button or f5

put as second line:

if ~nargin, error('no argument provided'); end

to test this

hth
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com