Input argument in a function as a string?
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Star Strider
2020 年 3 月 11 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Title についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!