which part of my logic is wrong?

1 次查看(过去 30 天)
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));

采纳的回答

Walter Roberson
Walter Roberson 2022-9-29
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));

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by