Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
Lieke
Lieke am 7 Dez. 2022
Beantwortet: Praveen Thota am 28 Dez. 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);

Antworten (1)

Praveen Thota
Praveen Thota am 28 Dez. 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

Kategorien

Mehr zu Axes Appearance finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by