plot a cube root function

조회 수: 11 (최근 30일)
Katie Shearer
Katie Shearer 2018년 5월 15일
댓글: Katie Shearer 2018년 5월 15일
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?

답변 (1개)

KSSV
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
KSSV
KSSV 2018년 5월 15일
편집: KSSV 2018년 5월 15일
I am getting a plot in 2017b. What version you are using?
Katie Shearer
Katie Shearer 2018년 5월 15일
I have been working in 2016a.
I am currently downloading 2018 but it is taking a while, I'll see if that fixes it.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by