I would like to know how to grab a specific number from an interval to test it and later be able to built a different functions under one graph. For example (in this case the 'x' variable),
x 0:.5:5;
Ids=ones(x);
figure;hold on;
for n = 1:5
if(x < 3.0) %problem here
Ids(n) = plot(x,x.^x);
else
if (x > 4.0) %and here
Ids(n) = plot(x,-x.^x);
end
end
end
EDIT
What I really want to do in MATLAB is to be able to do the following piecewise function:
y(x) = { 0 (t - 5) < 0
{ (t - 5)*(t - x) x < (t - 5)
{ (t + x^2) x >= (t - 5)
I don't seem to understand how to graph this function since x = 0:.5:10
and t = 0:.1:10
. I know how to do this without the t
, but I get lost when the t
is included and has different intervals compared to the x
.