plotting multiple values of a parameter on same figure

18 views (last 30 days)
I need to plot (OMEGA1 vs Ex_nz) and (OMEGA1 vs Ex_ny) for different values of amplitude a1= 0.1, a2=0.2, a3=0.3, a4=0.4 and a5=0.5. How can I plot these on the same figure just like the image attached? Please help
clear all; close all; clc;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+
% Simulation %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OMEGA1=1:1:14;%Fixed
OMEGA2=1:1:14;%Fixed
for num1=1:length(OMEGA1)
for num2=1:length(OMEGA2)
%value of constants
a1=0.1;
a2=0.2;
a3=0.3;
a4=0.4;
a5=0.5;
omega1=OMEGA1(num1);
omega2=OMEGA2(num2);
G=1;C12=0.01;C21=0.02;
dt=0.01; %step size
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x1(1)=0.5;
y1(1)=0.5;
x2(1)=1;
y2(1)=1;
for i=2:100000
x1(i)=x1(i-1)+((a1-x1(i-1)^2-y1(i-1)^2)*x1(i-1)-omega1*y1(i-1)+G*C12*(x2(i-1)-x1(i-1)))*dt;
y1(i)=y1(i-1)+((a1-x1(i-1)^2-y1(i-1)^2)*y1(i-1)+omega1*x1(i-1)+G*C12*(y2(i-1)-y1(i-1)))*dt;
x2(i)=x2(i-1)+((a2-x2(i-1)^2-y2(i-1)^2)*x2(i-1)-omega2*y2(i-1)+G*C21*(x1(i-1)-x2(i-1)))*dt;
y2(i)=y2(i-1)+((a2-x2(i-1)^2-y2(i-1)^2)*y2(i-1)+omega2*x2(i-1)+G*C21*(y1(i-1)-y2(i-1)))*dt;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Observation %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ksaix = [10 -7.6428 2.2896 0 -10.8200 0 -0 0 0 -0 0 -0 0 0 -0 -0];
ksaiy=[0.0000 2.2928 -2.2896 -0 0 -0 0 0 0 0 -0 -0 -0 0 -0 -0];
ksaix_ref=[1 0 1 0 -1.4 0 0 0 0 0 0 0 0 0 0 0];
ksaiy_ref=[0 0.3 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
count=0;
for N_m=3:16
count=count+1;
N_measurements=N_m;
N_basis=16;
SDx_sum=(ksaix(1)-ksaix_ref(1))^2+(ksaix(3)-ksaix_ref(3))^2+(ksaix(5)-ksaix_ref(5))^2;
SDy_sum=(ksaiy(2)-ksaiy_ref(2))^2;
SCx_sum=(ksaix_ref(1))^2+(ksaix_ref(3))^2+(ksaix_ref(5))^2;
SCy_sum=(ksaiy_ref(2))^2;
Ex_nz(count)=sqrt(SDx_sum)/sqrt(SCx_sum);
Ey_nz(count)=sqrt(SDy_sum)/sqrt(SCy_sum);
Data(count)=N_measurements/N_basis;
end
figure
hold on
plot (OMEGA1,Ex_nz,'o-r')
plot (OMEGA1,Ey_nz,'s-k')

Accepted Answer

madhan ravi
madhan ravi on 5 Jan 2021
Amplitude = rand(5, 1);
hold on
for k = 1 : numel(Amplitude) % this is an example of having different amplitudes, follow this for your example
x = linspace(0, 2*pi, 1e2);
plot(x, Amplitude(k) * sin(x));
end
legend("Amplitude = "+ Amplitude)

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!