Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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

3 visualizaciones (últimos 30 días)
Ethan Sehrt
Ethan Sehrt el 12 de Jun. de 2016
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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

Respuestas (1)

the cyclist
the cyclist el 12 de Jun. de 2016
Editada: the cyclist el 12 de Jun. de 2016
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.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by