Plotting a simple line graph from cell array
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Image Analyst
am 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]);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!