How can i mark the data points in the graph?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Md Monirul Islam
am 13 Mär. 2017
Kommentiert: Star Strider
am 14 Mär. 2017
I've plotted this figure. Now i want to mark the corresponding points. my code is
clc;
close all;
clear all;
x=[0:1:12];
SWR_Ratio=[1,1.28,1.8,2.5,3.2,4.2,5.4,7.25,10,11.32,11.8,12.85,20];
SWR_Deflection=[0,2.2,5,7.5,10,12.5,14.5,17.5,20,22.2,25.1,28.5,30];
figure(1)
subplot('211')
loglog(x,SWR_Ratio,'r')
title('Standing Wave Ratio (SWR) vs Attenuation')
xlabel('Attenuation(dB)')
ylabel('SWR')
grid on
subplot('212')
semilogx(x,SWR_Deflection)
title('SWR deflection vs Attenuation')
% legend('semilogx')
xlabel('Attenuation(dB)')
ylabel('SWR deflection')
axis([0 100 0 100])
0 Kommentare
Akzeptierte Antwort
Star Strider
am 13 Mär. 2017
You do not say how you want to ‘mark the corresponding points’.
Two possibilities:
One is to include a marker with the plot:
loglog(x,SWR_Ratio,'-rp')
and:
semilogx(x,SWR_Deflection, '-p')
2 Kommentare
Star Strider
am 14 Mär. 2017
My pleasure.
Use the text function for that. (I already linked to it in my original Answer.) It has a number of name-value pairs that will allow you align each one correctly.
This works:
x=[0:1:12];
SWR_Ratio=[1,1.28,1.8,2.5,3.2,4.2,5.4,7.25,10,11.32,11.8,12.85,20];
SWR_Deflection=[0,2.2,5,7.5,10,12.5,14.5,17.5,20,22.2,25.1,28.5,30];
figure(1)
subplot('211')
loglog(x,SWR_Ratio,'r')
title('Standing Wave Ratio (SWR) vs Attenuation')
xlabel('Attenuation(dB)')
ylabel('SWR')
grid on
pt_str = sprintf('(%d,%g)\n', [x(:) SWR_Ratio(:)]');
pt_cell = regexp(pt_str, '\n', 'split');
text(x, SWR_Ratio, pt_cell(1:end-1), 'HorizontalAlignment','left', 'VerticalAlignment','bottom', 'FontSize',8)
subplot('212')
semilogx(x,SWR_Deflection)
title('SWR deflection vs Attenuation')
% legend('semilogx')
xlabel('Attenuation(dB)')
ylabel('SWR deflection')
axis([0 100 0 100])
pt_str = sprintf('(%d,%g)\n', [x(:) SWR_Deflection(:)]');
pt_cell = regexp(pt_str, '\n', 'split');
text(x, SWR_Deflection, pt_cell(1:end-1), 'HorizontalAlignment','left', 'VerticalAlignment','bottom', 'FontSize',8)
The ‘pt_str’ assignment creates the point label string, ‘pt_cell’ creates a cell array from them because the text function wants them as a cell array (the last entry is blank, so I removed it with the ‘(1:end-1)’ subscript reference), and the text call plots the labels.
You will have to experiment to get the labels to display as you want them to.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Objects finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!