for loops with x y coordinates

3 views (last 30 days)
Enzo
Enzo on 8 Dec 2022
Commented: Mathieu NOE on 8 Dec 2022
Hi everyone,
I am having an hard time trying to find a way to plot multiplke lines made by 2 point, where one of them is always the same (all the lines have the same origin).
M1 and I1 are the origin for all the lines.
J and WZ are the coordinates of multiple points (in this specific case I only have 5 points). I would like to have a for loop which creates 1. a matrix with all the 5 lines 2. a plot where all the lines are plotted together.
I have tried to create 2 matrices (coordinates and min_peak in order to have some more easily handled object, but I am stuck. I am getting a non sense result right now, displayed in the following pic:
this is my code, where I get an hideous outcome.
thanks for you help
[M1,I1] = min(mean(TD_32(:,19,:),3));
onset_range = 2500:5000;
where = mean_LFP_fil_2(2500:5000,19)';
[J,WZ] = findpeaks(where,MinPeakHeight=-20);
a = length(WZ);
coordinates = [WZ+2500;J];
min_peak = [M1; I1];
for peaks = length(coordinates)
entire = mean_LFP_fil_2(:,19)';
fig_name_199 = ['peaks slope' num2str(a)];
figure(111)
plot(entire)
title(strn)
subtitle(fig_name_199)
hold on
xline(2500,'--r')
xline(5000,'--r')
hold on
line(min_peak,coordinates)
saveas(gcf,[main_folder,filesep,subfolder,filesep,fig_name_199],'png')
% for k=1:b
% slope(k) = (peaks+2500-M)/(peaks-I);
% end
end
  1 Comment
Mathieu NOE
Mathieu NOE on 8 Dec 2022
hello
1/ we don't have the data (TD_32 , mean_LFP_fil_2 ... ) to help fix your code
2/ maybe a sketch of what the results should looks like would help. it's still unclear to me

Sign in to comment.

Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!