Cell Arrays Graph Plot

1 回表示 (過去 30 日間)
RDG
RDG 2012 年 9 月 5 日
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 件のコメント
per isakson
per isakson 2012 年 9 月 5 日
Why use a cell array in the first place?

サインインしてコメントする。

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 5 日
set(gca,'xlim',[1 15])
  1 件のコメント
RDG
RDG 2012 年 9 月 5 日
Thank you Azzi. However, I just realized that I missed out an important piece of information. Kindly review the question.
Sorry for the inconvenience.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by