which part of my logic is wrong?

1 vue (au cours des 30 derniers jours)
2NOR_Kh
2NOR_Kh le 29 Sep 2022
Commenté : 2NOR_Kh le 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));

Réponse acceptée

Walter Roberson
Walter Roberson le 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));
  1 commentaire
2NOR_Kh
2NOR_Kh le 29 Sep 2022
thank u so much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by