Clear Filters
Clear Filters

mapping bode plot for Low Pass Filter

5 views (last 30 days)
Grant pixley
Grant pixley on 12 Jan 2024
Answered: AMIT SURYAVANSHI on 13 Jan 2024
Can someine please tell me what I am doing wrong with my code here
R = 1000;
C = 100*10^(-9);
tau = R*C;
w = 0:100:100000;
x = ((1-((w)*tau)^2)/((w)*tau)^2)+9;
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.
G = 1/(sqrt(x));
plot(w,G);

Answers (2)

Star Strider
Star Strider on 12 Jan 2024
Edited: Star Strider on 12 Jan 2024
You need to do element-wise exponentiation (.^) and division (./) —
R = 1000;
C = 100*10^(-9);
tau = R*C;
w = 0:100:100000;
x = ((1-((w)*tau).^2)./((w)*tau).^2)+9;
G = 1./(sqrt(x));
plot(w,G);
See the documentation section on Array vs. Matrix Operations for details.
figure
semilogx(w,mag2db(G/max(G)))
axis('padded')
EDIT — Added second plot.
.

AMIT SURYAVANSHI
AMIT SURYAVANSHI on 13 Jan 2024
%so u r dealing with vectors their is a mistake with the x variable and this line
&x = ((1-((w)*tau)^2)/((w)*tau)^2)+9;
%the correc ted code is
R = 1000;
C = 100 * 10^(-9);
tau = R * C;
w = 0:100:100000;
x = ((1 - ((w) * tau).^2) / ((w) * tau).^2) + 9;
G = 1 ./ sqrt(x);
plot(w, G);
%the last third line is corrrected with . operator which is used in the vector element by element %multiplication just be careful while using the vector decide wheather u want to use the normal vector %multiplication or elementwise multiplication

Tags

Community Treasure Hunt

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

Start Hunting!