Plotting a simple line graph from cell array
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Greetings, I am trying to plot a 2D-line graph from the contents of a cell array but I am not able to achieve it. A simple code is attached as below and my objective is to plot a real-time graph of the x_value against counter. Thank you in advance for your help.
for i=1:5
x_value{i}=i+1
counter=i
end
0 commentaires
Réponse acceptée
Image Analyst
le 1 Sep 2012
If you can't avoid x_value being a cell array (instead of just a regular normal numerical array), then use cell2mat(). Try this:
counter = 1 : 5
for k = counter
x_value{k} = k + 1;
end
double_x = cell2mat(x_value)
plot(counter, double_x, 'bo-', 'LineWidth', 3, 'MarkerSize', 20);
grid on;
xlabel('counter', 'FontSize', 30);
ylabel('x value', 'FontSize', 30);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Annotations 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!