フィルターのクリア

I am getting this error- "Vectors must be the same lengths.". Also please explain why its showing this error as I am plotting a funtion with 'x' as variable with defined vector.

2 ビュー (過去 30 日間)
clear all
rr=0.99997622; % reflectivity of the cavity
r=sqrt(rr);
finesse=pi.*sqrt(rr)./(1-rr); % finesse of the cavity
fsr=10^9;
x=-9e4:10:9e4; % frequnecy detuning
z=x./fsr;
FWHM=fsr./finesse;
mod=40e6; % modulation frequency to the laser
m=mod./fsr;
g=r.*(exp(((x./fsr).*(2.*pi)).*1i)-1)./(1-(r.^2).*exp(((x./fsr).*(2.*pi)).*1i));
abg=abs(g);
sg=power(abg,2);
dfg=diff(sg);
y=m.*dfg;
plot(x,y)

採用された回答

Mischa Kim
Mischa Kim 2014 年 6 月 23 日
編集済み: Mischa Kim 2014 年 6 月 23 日
Jayash, with the diff command you compute the difference between elements in a vector thereby reducing the number of elements by one. Use instead
plot(x(2:end),y)
  3 件のコメント
Mischa Kim
Mischa Kim 2014 年 6 月 23 日
a = [1 2 10];
b = diff(a)
b =
1 8
As explained above, diff computes the differene btw. vector elements. Therefore, b (in this case) only has two elements, not three.
Jose Cruz
Jose Cruz 2019 年 9 月 21 日
Mischa,
What if my problem is similar but I need to multiply the Diff () = dVdt [1369 x 1] with V [1370 x 1] equation. How can I add to the lenght of dVdt?
Matrix dimensions must agree.
Error in homework_1_P2 (line 40)
Inertia = (1.1*Mv*(dVdt).*V)./1000; % kW
load CYC_FUDS.mat
t = cyc_mph(:,1); % Time [s]
Vmph = cyc_mph(:,2); % Velocity [mph]
V = Vmph.*(1609/3600); % Velocity [m/s]
dVdt = (diff(V)./diff(t)); % Accel. m/s^2
Inertia = (1.1*Mv*(dVdt).*V)./1000; % kW

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAssembly についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by