Creating another function by extension of an existing function
1 view (last 30 days)
Show older comments
I have a function defined as
p = inline('(t>=0)&(t<1)','t');
with t being t=(-1:0.01:2);
I am trying to create another function
r(t)=t*p(t);
I keep getting errors saying ERROR using *, or mtimes not defined for the inline function, or that subscript indices must either be real or positive integers (when I transpose t that is).
Any help would be great. Im new to MATLAB.
0 Comments
Answers (1)
Walter Roberson
on 29 Sep 2013
p = @(t) (t>=0)&(t<1);
r = @(t) t .* p(t);
1 Comment
Jan
on 30 Sep 2013
@Umair: Using inline is still supported for backward compatibility. But anonymous function are working for many years now, so prefer them.
See Also
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!