Im getting a blank graph, and alot of errors.

6 visualizaciones (últimos 30 días)
John
John el 10 de Mzo. de 2023
Comentada: Star Strider el 10 de Mzo. de 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);

Respuesta aceptada

Star Strider
Star Strider el 10 de Mzo. de 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 comentarios
John
John el 10 de Mzo. de 2023
Thank you so much!
Star Strider
Star Strider el 10 de Mzo. de 2023
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by