Hi! please some about this Matlab code...l face difficulty to really plot frequency response of laser diode with feedback.thanks...
Show older comments
%%Matlab code to find the frequency response of Single Duffing oscillator
clear all;
% Given values
eps = 1/30; % Nonlinear Parameter
alpha =0.937; % Forcing amplitude
T = 1000; % linear damping
ib=2.8; % Primary resonance
m=0.02;
w0=30;
a=linspace(0.01,8.5,100); % Range of a
%Finding the values of excitation frequency Omega/w0= F and G.
% And corresponding eigen values
%
for ii=1:1:length(a)
F(ii)=1-(eps^2)/2*((a(ii)^2)/12-(T*ib*m/(2*a(ii)))^2)+eps*T*ib*m/(2*a(ii))*sqrt((eps*T*ib*m/(2*a(ii)))^2+4-(eps*a(ii))^2/6);
lamF1=w0*sqrt(-(F(ii)-1+(1+2*eps)/24*(eps*a(ii))^2)*(F(ii)-1+((eps*a(ii))^2)/24))-(eps*alpha);
lamF2=-w0*sqrt(-(F(ii)-1+(1+2*eps)/24*(eps*a(ii))^2)*(F(ii)-1+((eps*a(ii))^2)/24))-(eps*alpha);
G(ii)=1-eps^2/2*((a(ii)^2)/12-(T*ib*m/(2*a(ii)))^2)-eps*T*ib*m/(2*a(ii))*sqrt((eps*T*ib*m/(2*a(ii)))^2+4-((eps*a(ii))^2)/6);
lamG1=w0*sqrt(-(G(ii)-1+(1+2*eps)*((eps*a(ii))^2)/24)*(G(ii)-1+((eps*a(ii))^2)/24))-(eps*alpha);
lamG2=-w0*sqrt(-(G(ii)-1+(1+2*eps)*((eps*a(ii))^2)/24)*(G(ii)-1+((eps*a(ii))^2)/24))-(eps*alpha);
if lamF1==conj(lamG1)% % To terminate the loop
break
else
%if gamma>0 % For spring hardening effect
plot(G(ii),a(ii),'b.');
hold on
FG=(F(ii)-1+(1+2*eps)/24*(eps*a(ii))^2)*(F(ii)-1+((eps*a(ii))^2)/24)*w0^2+(eps*a(ii))^2;
if FG<0
plot(F(ii),a(ii),'r.');
else
plot(F(ii),a(ii),'b.');
end
%else
plot(F(ii),a(ii),'b.');
hold on
GF=(G(ii)-1+(1+2*eps)/24*(eps*a(ii))^2)*(G(ii)-1+((eps*a(ii))^2)/24)*w0^2+(eps*a(ii))^2;
if GF<0
plot(G(ii),a(ii),'r.');
else
plot(G(ii),a(ii),'b.');
end
%end
end
end
xlim([-2.5,2.5]); % Range of x-axis
ylim([0,70]); %Range of y-axis
xlabel('\Omega/\omega_{0}'); % Label of x-axis
ylabel('a'); % Label of y-axis
%title('Frequency response of a nonlinear system with \beta=0.05, q=0.2,\gamma=0.5, \epsilon=1')
% title('Effect of forcing paramter q for the system with \beta=0.05,\gamma=0.5, \epsilon=1')
% title('Effect of damping paramter beta for the system with q=0.2,\gamma=0.5, \epsilon=1')
%title('Effect of nonlinear paramter \gamma for the system with \beta=0.05,q=0.2, \epsilon=1')
title('Frequency response of a nonlinear system with \beta=0.05, q=0.2\gamma=0.5, \epsilon=1');
6 Comments
Walter Roberson
on 19 Feb 2021
please explain what difficulty you are observing.
francois landry seh ngono
on 19 Feb 2021
Edited: francois landry seh ngono
on 19 Feb 2021
dpb
on 19 Feb 2021
...
if FG<0
plot(F(ii),a(ii),'r.');
else
plot(F(ii),a(ii),'b.');
end
%else
plot(F(ii),a(ii),'b.');
...
Don't know what you're trying to do, but the above code will always output a blue dot (which may not even be visible as a single pixel on the screen depending on monitor, etc.). The if...else...end block is of no consequence because it is followed by the unconditional plot() instruction that outputs the same value.
If you're trying to do a dynamic plot of trajectory, may want to look at the animatedline feature.
francois landry seh ngono
on 19 Feb 2021
francois landry seh ngono
on 19 Feb 2021
Alireza Babaei
on 7 Mar 2022
Hello dear scholars,
I have kind of same problem with plotting the frequency response curve of Duffing equation.
Would you please share your code with me?
Thanks!
Answers (1)
Vu The
on 5 Dec 2021
0 votes
I'm interested in matlab code to plot frequency response. So, would you like to help me about it!
Please support me to build this code. Thanks so much
My address e-mail: thevutb@gmail.com
Categories
Find more on Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!