which part of my logic is wrong?

1 view (last 30 days)
2NOR_Kh
2NOR_Kh on 29 Sep 2022
Commented: 2NOR_Kh on 29 Sep 2022
I wanna plot the equation given below for w=(3:0.01:7)*1e6 and the written values in the code, I should have a plot of R based on w but the R I calculated in the code is a number instead of a vector. which part I wrong?
this is the equation:
clear all;
close all;
z1=34e6;
z2=7.14e6;
z3=1.5e6;
l=8.355e-5;
c2=1673;
w=(3:0.01:7)*1e6;
[m,n]=size(w);
R=((1-z1/z3)*cos(l.*w/c2) + 1j*(z2/z3-z1/z2)*sin(l.*w/c2))/((1+z1/z3)*cos(l.*w/c2) + 1j*(z2/z3+z1/z2)*sin(l.*w/c2));
plot(w,abs(R));

Accepted Answer

Walter Roberson
Walter Roberson on 29 Sep 2022
You used the / operator. The / operator is matrix division. P/Q is approximately P*pinv(Q) . In situations such as yours with row vector P and Q, P/Q is approximately a fitting operation. The element-by-element division operator is ./
z1=34e6;
z2=7.14e6;
z3=1.5e6;
l=8.355e-5;
c2=1673;
w=(3:0.01:7)*1e6;
[m,n]=size(w);
R = ((1-z1/z3)*cos(l.*w/c2) + 1j*(z2/z3-z1/z2)*sin(l.*w/c2)) ./ ((1+z1/z3)*cos(l.*w/c2) + 1j*(z2/z3+z1/z2)*sin(l.*w/c2));
plot(w,abs(R));

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!