How to plot a cell array containing characters?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everyone.
I have a cell array (1x1000) that looks like this:
comment=[artefact artefact 0 0 0 0 ...] ;
How can I plot the strings of this array against other values already plotted as lines?
3 commentaires
Image Analyst
le 19 Avr 2022
Again, attach your cell array with the paperclip icon
save('Answers.mat', 'comment');
after you read this link:
Réponses (1)
Voss
le 15 Avr 2022
% you have a 1x1000 cell array called 'comment':
comment = repmat({0},1,1000);
comment([1 2]) = {"artefact"};
disp(comment);
% and you have already plotted the lines:
figure
xlim([0 5]*1e6);
ylim([-4000 4000]);
hold on
plot([0 0 NaN 1.3 1.3 NaN 4.52 4.52 NaN]*1e6,[-4000 4000 NaN -4000 4000 NaN -4000 4000 NaN],'--r');
% here's how you can make the texts:
text(0,0,comment{1});
text(1.3e6,0,comment{2},'Rotation',90)
text(4.52e6,0,comment{2},'Rotation',-45);
4 commentaires
Voss
le 20 Avr 2022
You're welcome! If you have any other questions, let me know. Otherwise, if my answer satisfactorily addresses what you're trying to do, please click 'Accept this Answer'. Thanks!
Voir également
Catégories
En savoir plus sur Cell Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


