Why doesn't matlab plot both my graphs?
Afficher commentaires plus anciens
I want to plot 4 functions on the same graph (I only know VERY BASIC matlab - please, no negative comments, I'm enrolled in a course for this, and this is the weeks practice q's). but every time I plot more than 1 graph it throws an error and doesn't plot it. I cannot understand why, as in previous questions I have done exactly the same thing.
This is my code below:
>> d0 = @(t) 10.*cos(t.*(2.*pi))
d0 =
function_handle with value:
@(t)10.*cos(t.*(2.*pi))
>> fplot(d0, [0,5], 'k')
>> fplot(d0, [0,5], 'k')
>> hold on
The above part works fine, but then I try to do the second graph:
>> d1 = @(t) (10.*cos(t.*(2.*pi)))/exp(t.*0.2)
d1 =
function_handle with value:
@(t)(10.*cos(t.*(2.*pi)))/exp(t.*0.2)
>> fplot(d1, [0,5], '--r')
Warning: Function behaves unexpectedly on array inputs. To improve performance,
properly vectorize your function to return an output with the same size and shape as
the input arguments.
> In matlab.graphics.function.FunctionLine>getFunction
In matlab.graphics.function.FunctionLine/updateFunction
In matlab.graphics.function.FunctionLine/set.Function_I
In matlab.graphics.function.FunctionLine/set.Function
In matlab.graphics.function.FunctionLine
In fplot>singleFplot (line 226)
In fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 185)
In fplot>vectorizeFplot (line 185)
In fplot (line 156)
When I graph d1 first, it works. But then when I try to do d0 it doesn't do anything.
Thank you for any help and guidance.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Graph and Network Algorithms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!