在matlab中绘制一个非线性函数
我对Matlab非常陌生,在使用Matlab绘制这个非线性2D函数图时遇到问题 运行下面的程序后会产生很多错误在matlab中绘制一个非线性函数,matlab,Matlab,我对Matlab非常陌生,在使用Matlab绘制这个非线性2D函数图时遇到问题 运行下面的程序后会产生很多错误 fun1 = 20 + 10 + 15; fun2 = 20 + (x * 0.00125 ) + 15; fun3 = (x * 0.0025) + 15; fplot(fun1,[0 8000]) fplot(fun2,[8000 16000]) fplot(fun2,[16000 positive infinity]) 我非常感谢你的努力和好意,感谢你回答我的问题 致意首
fun1 = 20 + 10 + 15;
fun2 = 20 + (x * 0.00125 ) + 15;
fun3 = (x * 0.0025) + 15;
fplot(fun1,[0 8000])
fplot(fun2,[8000 16000])
fplot(fun2,[16000 positive infinity])
我非常感谢你的努力和好意,感谢你回答我的问题
致意首先创建一个包含函数定义的文件
fun.m
function y = fun(x)
if x < 8000
y = 20 + 10 + 15;
elseif x < 16000
y = 20 + (x * 0.00125) + 15;
else
y = x * 0.0025 + 15;
end
end
导致
前三个表达式不定义函数。请阅读有关正确语法的说明
fun1 = @(x)(20 + 10 + 15);
如果你做一些阅读,你会发现
对于fplot(乐趣、限制)
一定很有趣
- 函数名
- 带有变量x的字符串,可以传递给eval,例如'sin(x)'、'diric(x,10')或'[sin(x),cos(x)]'
- 函数句柄
fplot(fun2,[16000 inf])
虽然我不认为这会给你带来什么好结果
fplot(fun2,[16000 inf])