plot a cube root function
5 次查看(过去 30 天)
显示 更早的评论
My Script code is as follows:
clear all; close all;
figure;
fplot(@(x) ((2*x+5)^(1/3)),[2 3], 'LineStyle', '-', 'Color', 'b', 'LineWidth', 1);
ti=title('g(x) = (2x+5)^1^/^3');
set([ti,gca],'fontsize',10);
The error message is:
Warning: Function fails on array inputs. Use element-wise operators to increase speed.
> In matlab.graphics.function.FunctionLine>getFunction
In matlab.graphics.function.FunctionLine/set.Function_I
In matlab.graphics.function.FunctionLine/set.Function
In matlab.graphics.function.FunctionLine
In fplot>singleFplot (line 223)
In fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 182)
In fplot>vectorizeFplot (line 182)
In fplot (line 153)
In Assignment2Question1aii (line 3)
How can I fix this?
0 个评论
回答(1 个)
KSSV
2018-5-15
Use this line:
fplot(@(x) ((2*x+5).^(1/3)),[2 3], 'LineStyle', '-', 'Color', 'b', 'LineWidth', 1);
as a function. Read about matlab element by element operations.
3 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!