Borrar filtros
Borrar filtros

y[n] = 3*2/3^n*cos(pi)

2 visualizaciones (últimos 30 días)
Lieke
Lieke el 7 de Dic. de 2022
Respondida: Praveen Thota el 28 de Dic. de 2022
I want to plot the function above. If i only fill in 3*2/3^n it works and also only cos(pi) works but when i put them in as 3*2/3^n*cos(pi) it doesn't work.
The error:
Error using ^
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To operate on each element of the matrix individually, use POWER (.^) for elementwise power.
Error in Practicum_3_Matlab (line 32)
y8 = 3*2/3^n*cos(pi*n+0);

Respuestas (1)

Praveen Thota
Praveen Thota el 28 de Dic. de 2022
Hi,
I understand that you want to plot a custom function but encountering an error message.
Use of element-wise operators for power and division should resolve the issue.
The function should be written like this
>> y = 3*2./3.^n*cos(pi);
You can also refer to the element-wise operations MathWorks Documentation for further reference

Categorías

Más información sobre Axes Appearance en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by