Im getting a blank graph, and alot of errors.

4 次查看(过去 30 天)
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);

采纳的回答

Star Strider
Star Strider 2023-3-10
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!
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Function Creation 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by