Info

此问题已关闭。 请重新打开它进行编辑或回答。

What did I do wrong with my code to get this "^" error?

2 次查看(过去 30 天)
I input an equation as y=((x^2)*sin(x))/exp(x) and defined x as x=logspace(0,6,7); in the script. When I run it, i get a message saying "error using ^. Inputs must be a scalar and a square matrix."
I'm trying to evaluate the different y value outputs with a range of x inputs as 1,10,100,1000,10000,100000,1000000 using a dot product feature

回答(1 个)

the cyclist
the cyclist 2016-6-12
编辑:the cyclist 2016-6-12
Try
y=((x.^2).*sin(x))./exp(x)
Notice that I added some periods, to denote element-wise operations.
You might want to read this page about array and matrix operations.

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by