How to plot a marked point in a graph and connect it with other points?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Vishnuvardhan Naidu Tanga
am 14 Okt. 2021
Kommentiert: Mathieu NOE
am 15 Okt. 2021
Hello all,
I am trying to mark a specific point in the plot and need to connect it with other points. I have tried using plot(x_pos, y_pos) but i am getting an error. I have marked the points in the excel data. I am also attaching a demo plot on what i required. Please kindly help me. Thanks in advance.
My code:
Z = readtable('Atq100.xlsx') ;
data = table2array(Z) ;
N = size(data,2);
Nsp = N/2;
ttlc = {'x=10mm', 'x=250mm', 'x=500mm', 'x=1000mm', 'x=1500mm'};
xofst = [10 250 500 1000 1500];
figure
ylim([-1 1]*250)
xlim([0 1750])
hold on
for k = 1:Nsp
col = [2 1]+2*(k-1);
famp = 5;
datacol1 = data(:,col(1))*famp+xofst(k);
hp(k) = plot(datacol1, data(:,col(2)), 'LineWidth',2);
minx(k) = min(datacol1);
maxx(k) = max(datacol1);
plot([1;1]*[minx(k) maxx(k)], ([1;1]*ylim).', ':k', 'LineWidth',1)
plot([minx(1) maxx(1)]-minx(1)+minx(k), [0 0], '-k', 'LineWidth',1)
Line_Coordinates = [minx(1) maxx(1)]-minx(1)+minx(k);
LineLength = diff(Line_Coordinates);
end
hold off
hl = legend([hp], ttlc, 'Location','northeastoutside');
0 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 14 Okt. 2021
hello
this is a first attempt
the outer lines was fairly easy to plot
the two inner lines , it's a bit coded just to show a principle but there is yet no "scientific" method to pick the points . Now this is where you need to tell more about how to choose the inner points
so far this is where I am :
Z = readtable('Atq100.xlsx') ;
data = table2array(Z) ;
N = size(data,2);
Nsp = N/2;
ttlc = {'x=10mm', 'x=250mm', 'x=500mm', 'x=1000mm', 'x=1500mm'};
xofst = [10 250 500 1000 1500];
figure(1)
ylim([-1 1]*250)
xlim([0 1750])
hold on
for k = 1:Nsp
col = [2 1]+2*(k-1);
famp = 5;
datacol1 = data(:,col(1))*famp+xofst(k);
datacol2 = data(:,col(2));
minx(k) = min(datacol1);
maxx(k) = max(datacol1);
miny(k) = min(datacol2);
maxy(k) = max(datacol2);
%%%%%%%%%%%%%%%%%%%%% special code for inner line %%%%%%%%%%%%%%%%%%%%%
ll = length(datacol1);
ind1 = round(ll/(3.5+0.5*k));
ind2 = ll - round(ll/(2.5+0.5*k));
y_pos(k) = datacol2(ind1);
y_neg(k) = datacol2(ind2);
x_pos(k) = datacol1(ind1);
x_neg(k) = datacol1(ind2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hp(k) = plot(datacol1, datacol2, 'LineWidth',2);
plot([1;1]*[minx(k) maxx(k)], ([1;1]*ylim).', ':k', 'LineWidth',1)
plot([minx(1) maxx(1)]-minx(1)+minx(k), [0 0], '-k', 'LineWidth',1)
Line_Coordinates = [minx(1) maxx(1)]-minx(1)+minx(k);
LineLength = diff(Line_Coordinates);
end
plot(minx,miny,'dr',minx,maxy,'db')
plot(minx,miny,'r',minx,maxy,'b')
plot(x_pos,y_pos,'dr',x_neg,y_neg,'db')
plot(x_pos,y_pos,'--r',x_neg,y_neg,'--b')
hold off
hl = legend([hp], ttlc, 'Location','northeastoutside');
6 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Sparse Matrices 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!