Filter löschen
Filter löschen

Cell Arrays Graph Plot

1 Ansicht (letzte 30 Tage)
RDG
RDG am 5 Sep. 2012
Thank you for your attention. Kindly refer to the code excerpt. (It's the most concise version of code that I have written)
count = 1 : 15;
randvar=cell(50,1);
for h=1:50
randvar{h}=zeros(10,4);
randvar{h}(:,1)=randi(10,10,1);
randvar{h}(:,2)=randi(5,10,1);
randvar{h}(:,3)=randi(10,10,1);
randvar{h}(:,4)=randi(17,10,1);
end
for counter=count
for h=1:50
a{h}=0;
for i=1:10
for j=1:10-i
if randvar{h}(i,1) ~= randvar{h}(i+j,1)
if randvar{h}(i,2)==randvar{h}(i+j,2)
if randvar{h}(i,3)==randvar{h}(i+j,3)
if randvar{h}(i,4)==randvar{h}(i+j,4)
a{h}=a{h}+10;
else
a{h}=a{h}+0;
end
end
end
end
end
end
end
end
double_a = cell2mat(a);
plot(counter, double_a, 'bo-', 'LineWidth', 2, 'MarkerSize', 10);
grid on;
xlabel('counter', 'FontSize', 15);
ylabel('a value', 'FontSize', 15);
When it runs, the x-axis (counter) displays a continuous range of 14-16. What should I do to achieve a discrete range of 1-15 (as specified in the count variable). The a{h} value at every iteration should also correspond to the x-axis.
I'm relatively new in cell arrays graph plots. Any help rendered would be much appreciated.
  1 Kommentar
per isakson
per isakson am 5 Sep. 2012
Why use a cell array in the first place?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 5 Sep. 2012
set(gca,'xlim',[1 15])
  1 Kommentar
RDG
RDG am 5 Sep. 2012
Thank you Azzi. However, I just realized that I missed out an important piece of information. Kindly review the question.
Sorry for the inconvenience.

Melden Sie sich an, um zu kommentieren.

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