How can one, out of several xlines in a script be ignored when the x-input value is missing?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have several datasets stored as different workspaces. I need to plot these data and mark specific timepoints of blood sampling with an xline. Since there are many plots to be done, I have tried to automate this by using a script in which I only have to note the time that is to be highlighted.
My problem is, for different plots different data samplings is missing. For example:
x = linspace(0,100,10)
y = randi([0 10],1,10)
plot(x,y)
a = input('1:')
b = input('2:')
c = input('3:')
xline(a,'-k')
xline(b,'-r')
xline(c,'-b')
If one of the three timepoints ("1-3") is missing, I want to skip that entry by pressing 'Enter'. How can I get the script not to execute/draw the xline with the missing x-value (or empty array [ ] that is created with the blank input)?
Thank you in advance!
0 Commenti
Risposta accettata
Adam Danz
il 3 Lug 2019
Modificato: Adam Danz
il 3 Lug 2019
You can plot all lines at the same time, skipping empty values. Then you can set the colors of the line.
a = input('1: ');
b = input('2: ');
c = input('3: ');
xlh = arrayfun(@(x)xline(x,'-'),[a,b,c]);
colors = {'k','r','b'};
set(xlh, {'color'}, colors(~cellfun(@isempty,{a,b,c}))')
*This solution was updated after realizing that xline() does not accept NaN values.
4 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Geometric Transformation and Image Registration in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!