How to create legend for each point?

24 views (last 30 days)
Isa Ilkan Duran
Isa Ilkan Duran on 30 Jun 2015
Answered: Azzi Abdelmalek on 30 Jun 2015
Hi !
Im trying to create a legend for each point on the interpolated data set. So for point (0.6672,vq2(1)) the legend should be 2 and for the other points 1 and so on. Can someone explain me why this doesnt work? Or does someone know a better method?
Thanks
% Interpolation in order to find inflow velocity amplitude in given
% frequencies.
LeNa = [2 1 0.6];
xq = [0.6672 0.5158 0.3654]; % Given frequencies
vq2 = interp1(omega_w,Up_amp,xq,'linear')
figure()
plot(xq,vq2,'+b')
Legend = cell(size(LeNa));
for i = 1:length(LeNa)
Legend{i} = ['\lambda/L_{pp} = ', num2str(LeNa(i))];
end
legend(Legend);

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 30 Jun 2015
%Look at this example which doesn't work
t=[0 1 2 3 4 5]
y=sin(t)
plot(t,y)
leg={'0' '1' '2' '3' '4' '5'}
legend(leg)
If you want to get the 5 legends
plot(t,y)
hold on
for k=1:5
plot(t(k),y(k),'*')
end
legend(leg)

Community Treasure Hunt

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

Start Hunting!