Plotting a simple line graph from cell array

5 Ansichten (letzte 30 Tage)
RDG
RDG am 1 Sep. 2012
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

Akzeptierte Antwort

Image Analyst
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)

Kategorien

Mehr zu Line Plots 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!

Translated by