# Plot a bifurcation diagram for a 2 parameter family of 1D maps

조회 수: 12(최근 30일)
Bill Symolon 2017년 3월 5일
답변: Sam McDonald 2017년 3월 7일
Greetings,
I need to plot bifurcation diagrams for the following function: f = a + (bx)/(1+x^2) for a = [-5, 0] and b = [11, 12]. The code I have runs without errors and generates a figure, but there is no data on the plot. I'd appreciate any help you can provide.
if true
% Two parameter family of one-dimensional maps
% f = a + (b*x)/(1 + x^2)
a = [-5 0];
b = [11 12];
x = [0:4];
% Compute f(a) for a = -5 and a = 0
for b = [11 : 0.01 : 12];
f_a1 = a(1) + b*x / (1 + x.^2);
end
for b = [11 : 0.01 : 12];
f_a2 = a(2) + b*x / (1 + x.^2);
end
% Compute f(b) for b = 11 and b = 12
b = [11 12];
for a = [-5 : 0.01 : 0];
f_b1 = a + b(1)*x / (1 + x.^2);
end
for a = [-5 : 0.01 : 0];
f_b2 = a + b(2)*x / (1 + x.^2);
end
figure
subplot(4,1,1)
plot (f_a1, '-');
title('Bifurcation Diagram for a = -5')
xlabel('b = 11:12')
xlim([11 12])
ylabel('x = 0:4')
ylim([0 4])
subplot(4,1,2)
plot (f_a2, '-');
title('Bifurcation Diagram for a = 0')
xlabel('b = 11:12')
xlim([11 12])
ylabel('x = 0:4')
ylim([0 4])
subplot(4,1,3)
plot (f_b1, '-');
title('Bifurcation Diagram for b = 11')
xlabel('a = -5:0')
xlim([-5 0])
ylabel('x = 0:4')
ylim([0 4])
subplot(4,1,4)
plot (f_b2, '-');
title('Bifurcation Diagram for b = 12')
xlabel('a = -5:0')
xlim([-5 0])
ylabel('x = 0:4')
ylim([0 4])
end

댓글을 달려면 로그인하십시오.

### 채택된 답변

Sam McDonald 2017년 3월 7일
I will address the plotting issues. There are two reasons for not seeing anything plotted.
1. Your data is outside the x and y limits you have set for your plots. For example, after executing your code, the value for f_a1 is -1.8496. Using the "plot" command on a single vector (in this case a 1x1 vector) will result in plotting the value against the index of that value, such that the location of the data on the plot will be (1, -1.8496). Since you have set the axes limits to [11 12 0 4], you will not see that data point on the axes. Make sure you set appropriate axes limits for the range of data you expect to see.
2. The solid line style specifier ('-') you have chosen in the plot command will plot a line between two or more data points. Since you have only one data point, you won't see it plotted regardless of the first reason I mentioned above. To see even one data point, you could choose a marker specifier from the list on this documentation page:

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!