ginput, several curves in one plot

9 Ansichten (letzte 30 Tage)
kenoz
kenoz am 9 Mär. 2019
Kommentiert: kenoz am 12 Mär. 2019
Hi
So i have a 'ginput' command that produces a spectrum of a spot in an image. How do i plot all the points I select in the same graph, so that i can compare multiple spectra readily, please?
Thanks for the help

Antworten (1)

Image Analyst
Image Analyst am 9 Mär. 2019
Use plot and hold:
plot(spectralCurve1, '-', 'LineWidth', 2);
hold on;
plot(spectralCurve2, '-', 'LineWidth', 2);
plot(spectralCurve3, '-', 'LineWidth', 2);
etc.
  3 Kommentare
Image Analyst
Image Analyst am 11 Mär. 2019
No it didn't make it easier. For one, put all that squeeze stuff before the plot to make a single vector, and put the xlabel and ylabel on separate lines.
Then, I see no reason why you can't, in a loop, just put hold on, and plot your other curves that you got from other clicks. You didn't explain why it did not work. I'd do something like
for k = 1 : numCurves
figure(1) % Move to the image figure.
uiwait(helpdlg('Click on a point'));
(x, y) = ginput()
thisSpectrum = ......squeeze(.......
figure(2) % Move over to the plotting figure.
plot(thisSpectrum.......
hold on;
end
grid on;
Also, your badly-named a and b caused you to flip the rows and columns. a is x which is columns, so it comes second. In other words, it's not imageStack(ceil(a),ceil(b),:), it should really be imageStack(ceil(b),ceil(a),:). An all too common beginner's mistake, so you're not the only one.
kenoz
kenoz am 12 Mär. 2019
Thank you very much.
It worked.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Exploration 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!

Translated by