Effacer les filtres
Effacer les filtres

Im getting a blank graph, and alot of errors.

3 vues (au cours des 30 derniers jours)
John
John le 10 Mar 2023
Commenté : Star Strider le 10 Mar 2023
x = inline ('t>0', 't');
t1 = -2;
t2 = 6;
t = [t1, t2];
fplot (x, t)
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.
Error using string
Conversion to string from inline is not possible.

Error in matlab.graphics.function.mixin.Legendable/displayNames (line 36)
s.none = replace(string(fn),[".*" ".^" "./"],["*" "^" "/"]);

Error in matlab.graphics.function.FunctionLine/updateFunction

Error in matlab.graphics.function.FunctionLine/set.Function_I

Error in matlab.graphics.function.FunctionLine/set.Function

Error in matlab.graphics.function.FunctionLine

Error in fplot>singleFplot (line 245)
hObj = matlab.graphics.function.FunctionLine(fn{1},extraOpts{:},args{:});

Error in fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 200)
hObj = cellfun(@(f) singleFplot(cax,{f},limits,extraOpts,args),fn{1},'UniformOutput',false);

Error in fplot>vectorizeFplot (line 200)
hObj = cellfun(@(f) singleFplot(cax,{f},limits,extraOpts,args),fn{1},'UniformOutput',false);

Error in fplot (line 166)
hObj = vectorizeFplot(cax,fn,limits,extraOpts,args);

Réponse acceptée

Star Strider
Star Strider le 10 Mar 2023
Use an anonymous function instead of the deprecated inline function, and since the ‘x’ function actually returns a logical result, convert it to a numerical result by performing an arithmetic operation on it, here being a unary plus —
x = @(t) +t>0;
t1 = -2;
t2 = 6;
t = [t1, t2];
fplot (x, t)
xlabel('t')
ylabel('x')
... and the plot of the function magically appears!
.
  2 commentaires
John
John le 10 Mar 2023
Thank you so much!
Star Strider
Star Strider le 10 Mar 2023
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Function Creation dans Help Center et File Exchange

Tags

Produits


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by