Re: Inser text in graph



Thanks a lot for helping me. I have modified the code according to what Me. Nasser wrote. That is I don't have color_vec anymore, I am having annot instead, that's why I am getting the error

??? Error using ==> set
Color value must be a 3 element numeric vector

Error in ==> Trajectories_modified at 27
for ix=1:3,set(oh(ix*2),'color',annot(ix)),end

The code is

clear all; close all;
r_vec = [0.25, 0.5, 1];
annot = {'r','b','k'};
rho = 0.5;
n = 50;
Nit = 10;

figure(1);
hold on

for j = 1 : length(r_vec)
x_previous = ones(1,n);
x_next = x_previous;
time = linspace(0,r_vec(j),n);
% plot(time,x_next,'.') %why?
for i = 1: Nit
x_next = 1 - rho*x_previous.^2;
x_previous = x_next;
time = linspace(i*r_vec(j),(i+1)*r_vec(j),n);
plot(time,x_next,char(annot(j)),'linewidth',3)
end
end
[lh,oh]=legend({'r=0.25';'r=0.5';'r=1'});
for ix=1:3,set(oh(ix*2),'color',annot(ix)),end
%for ix=1:3,set(oh(ix*2),'color',color_vec(ix)),end
xlabel('t')
ylabel('x')

Thanks a lot in advance.
.