help-octave
[Top][All Lists]
Advanced

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

RE: Integration with quad


From: Allen.Windhorn
Subject: RE: Integration with quad
Date: Wed, 9 Dec 2009 13:56:00 -0600

-----Original Message-----
From: Søren Hauberg [mailto:address@hidden 

ons, 09 12 2009 kl. 20:07 +0100, skrev Thomas Göbel:
>> i want to integrate the following function:
>> 
>> function y = rect(t)
>> if t<=0.5
>>     rect=1
>> else
>>     rect=0
>> end
>> endfunction

> Your return value is called 'y', but you never define this in your
> function. Try something like
>
> function y = rect(t)
>  if t<=0.5
>    y=1
>  else
>    y=0
>  endif
> endfunction

You can also write:

function y = rect(t)
  y = (t<=0.5);
endfunction

This function will work on a vector.  Are there methods to "vectorize" other 
functions with less tractable conditional statements?

Regards,
Allen



reply via email to

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