Input argument in a function as a string?
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Jenniluyn Nguyen
il 11 Mar 2020
Risposto: Star Strider
il 11 Mar 2020
Hello,
I'm working on a function that's supposed to visualize large sets of data. This is what I have so far -
function visualize(data,xlabels,ylabels,titles,xticks)
hold on
for i = 1:length(data)
graph = plot(data(i,:));
pause(0.1);
end
graph.xlabel = xlabels;
graph.ylabel = ylabels;
graph.title = titles;
set(gca, 'XTickLabel', {xticks});
hold off
I realized that I'm not sure how to make it so the xlabel, ylabel etc. are assigned to the xlabels, ylabels input argument, which is supposed to be a string. Is there an explicit way to do this?
I'm also trying to figure out how to make xlabels, ylabels, titles, and ticks optional (so that there's a default option whenever it's not explicitly put.)
Thanks in advance!
0 Commenti
Risposta accettata
Star Strider
il 11 Mar 2020
It’s a bit more involved than that.
ax.XLabel.String = xlabels;
ax.YLabel.String = ylabels;
ax.Title.String = titles;
would work.
I’m not certain what you’re doing with respect to the loop. If you have different axis labels and titles for each plot, you‘ll need to include them in the loop and assign them each time, possibly subscripting them if there are different ones for each plot. Otherwise, they would only be assigned to the last plot.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Axis Labels 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!