plot multiple vertical line on the same graph
Ältere Kommentare anzeigen
Hello every one,
i would like to add many vertical lines in my gaph. The x-values where to draw them are stored in a table (index values [129x1). I have also tried to use (1x129) without success. I'am trying to call this coordinates but I am failing. I have tried to manually insert fake coordinates using several approaches and, as long I am not calling the coordinates from an array, everything works perfectly. Any idea how to deal with it?
see the code for more info.
in the attachments, you will find the graph where I would like to insert my vertical dotted lines.
%pefect like that, I just need to add chan33 for trigger or use lc variable
%as a map
figure(2)
Y = new_ch(:, 1:32).';
Y = Y ./ max(abs(Y), [], 1); % Divide by maximum value. Then all values are between -1 and 1
Y = Y + (1:32).';
plot(1:width(Y), Y);
hold on
set(gca,'xlim', [0 20000]) %set x-axis window diplayed
%xline(lc_swap) --> attempt n1 (fail)
%where lc swap is the table where
% for i = 1:length(lc_swap) --> attempt n2 (fail)
% xline(lc_swap(i));
% end
2 Kommentare
Y = rand(100,32);
Y = Y ./ max(abs(Y), [], 1); % Divide by maximum value. Then all values are between -1 and 1
Y = Y + (1:100).'
plot(1:32, Y);
idx = 1:10;
values = linspace(1,32,10);
xline(values(idx),'--')
idx = 1:10; % index values
values = linspace(1,32,10); % x vector
xline(values(idx),'--')
pass the vector with its index values
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Line Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
