Unsure what I did wrong
1 次查看(过去 30 天)
显示 更早的评论
I want to plot a graph of y against x:
x=[0:2*pi]
y=exp(1)^x
plot(x,y)
But this error showed:
Error using ^ (line 51)
Incorrect dimensions for raising a matrix to a power. Check that the matrix is
square and the power is a scalar. To perform elementwise matrix powers, use '.^'.
0 个评论
采纳的回答
David Hill
2020-2-15
x=0:.01:2*pi;
y=exp(1).^x;
plot(x,y)
2 个评论
David Hill
2020-2-15
.^ needed for element-wise array operations
0:.01:2*pi splits up the interval into finer steps for plotting
更多回答(1 个)
Steven Lord
2020-2-15
Don't try to raise exp(1) to the power of x. Just use exp on the array x directly.
x = 1:5;
y = exp(x);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Mobile Fundamentals 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!