How to plot different values on same figure?

27 views (last 30 days)
Heya :)
Heya :) on 4 Jan 2021
Commented: Heya :) on 5 Jan 2021
I need to plot (a vs Ex_nz) and (a vs Ex_ny) for different values of b= 0.1, b=0.2, b=0.3, b-0.4 and b=0.5. How can I plot these on the same figure just like the R in the image attached?
clear all; close all; clc;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Simulation %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x(1)=0;
y(1)=0;
a=1:1:14;
b=0.3;
for i=2:10000
x(i)=1-1.4*(x(i-1)^2)+y(i-1);
y(i)=b*x(i-1);
end
%plot(x,y,'.','MarkerSize',2)
%hold on
%xlabel('x')
%ylabel('y')
%title('henon map')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 (a,Ex_nz,'o-r')
plot (a,Ey_nz,'s-k')

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 4 Jan 2021
Edited: KALYAN ACHARJYA on 4 Jan 2021
Use yyaxis
Otherwise:
If you want to generate multiple plots with different values ​​of b, consider b as an array, and acess the individual value of b, by passing index position, say
b =[0.1576 0.9706 0.9572 0.4854 0.8003];
figure,
for j=1:length(b)
%Evauate plot data based on b(j)
........
y(i)=b(j)*x(i-1);
........
plot
hold on
end

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!