Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.46 KB | None | 0 0
  1. function sistem(p)
  2. A = zeros(1,6);
  3. p=rand(1,6);
  4. for i = 1:6
  5. A(i) = Bern(p(i));
  6. end
  7. % Create figure
  8. figure1 = figure;
  9.  
  10. % Create line
  11. annotation(figure1,'line',[0.0236486486486487 0.0802364864864865],...
  12. [0.50728729281768 0.50828729281768]);
  13.  
  14. % Create line
  15. annotation(figure1,'line',[0.224662162162163 0.288851351351352],...
  16. [0.581872928176794 0.582872928176794]);
  17.  
  18. % Create line
  19. annotation(figure1,'line',[0.223817567567568 0.288006756756757],...
  20. [0.722756906077347 0.723756906077346]);
  21.  
  22. % Create line
  23. annotation(figure1,'line',[0.223817567567568 0.224662162162163],...
  24. [0.722756906077346 0.580110497237568]);
  25.  
  26. % Create line
  27. annotation(figure1,'line',[0.344594594594596 0.408783783783785],...
  28. [0.728281767955799 0.729281767955799]);
  29.  
  30. % Create line
  31. annotation(figure1,'line',[0.343750000000002 0.407939189189191],...
  32. [0.58463535911602 0.58563535911602]);
  33.  
  34. % Create line
  35. annotation(figure1,'line',[0.40962837837838 0.410472972972975],...
  36. [0.728281767955799 0.585635359116021]);
  37.  
  38. % Create line
  39. annotation(figure1,'line',[0.160472972972973 0.347128378378378],...
  40. [0.322204419889502 0.323204419889503]);
  41.  
  42. % Create line
  43. annotation(figure1,'line',[0.161317567567568 0.225506756756757],...
  44. [0.653696132596685 0.654696132596685]);
  45.  
  46. % Create line
  47. annotation(figure1,'line',[0.160472972972973 0.160472972972973],...
  48. [0.653696132596685 0.323204419889503]);
  49.  
  50. % Create line
  51. annotation(figure1,'line',[0.131756756756757 0.161317567567568],...
  52. [0.510049723756906 0.511049723756906]);
  53.  
  54. % Create arrow
  55. annotation(figure1,'arrow',[0.0337837837837838 0.0625],...
  56. [0.504524861878453 0.50828729281768]);
  57.  
  58. % Create arrow
  59. annotation(figure1,'arrow',[0.596283783783785 0.645270270270272],...
  60. [0.482425414364641 0.483425414364641]);
  61.  
  62. % Create line
  63. annotation(figure1,'line',[0.514358108108109 0.54391891891892],...
  64. [0.476900552486187 0.477900552486188]);
  65.  
  66. % Create line
  67. annotation(figure1,'line',[0.402027027027028 0.511824324324324],...
  68. [0.349828729281767 0.348066298342541]);
  69.  
  70. % Create line
  71. annotation(figure1,'line',[0.512668918918921 0.512668918918919],...
  72. [0.661983425414361 0.345303867403315]);
  73.  
  74. % Create line
  75. annotation(figure1,'line',[0.409628378378379 0.43918918918919],...
  76. [0.66474585635359 0.66574585635359]);
  77.  
  78. % Create line
  79. annotation(figure1,'line',[0.494932432432434 0.516891891891892],...
  80. [0.659220994475136 0.660220994475138]);
  81.  
  82. % Create textbox
  83. if(A(1)==1)
  84. annotation(figure1,'textbox',...
  85. [0.077968146718146 0.450276243093922 0.0546332046332054 0.115706129965801],...
  86. 'String',{'A1'},...
  87. 'FitBoxToText','off',...
  88. 'BackgroundColor',[1 1 0]);
  89. else
  90. annotation(figure1,'textbox',...
  91. [0.077968146718146 0.450276243093922 0.0546332046332054 0.115706129965801],...
  92. 'String',{'A1'},...
  93. 'FitBoxToText','off',...
  94. 'BackgroundColor',[1 0 0]);
  95. end
  96. % Create textbox
  97. if(A(3)==1)
  98. annotation(figure1,'textbox',...
  99. [0.287427606177606 0.674033149171269 0.0546332046332054 0.115706129965801],...
  100. 'String',{'A3'},...
  101. 'FitBoxToText','off',...
  102. 'BackgroundColor',[1 1 0]);
  103. else
  104. annotation(figure1,'textbox',...
  105. [0.287427606177606 0.674033149171269 0.0546332046332054 0.115706129965801],...
  106. 'String',{'A3'},...
  107. 'FitBoxToText','off',...
  108. 'BackgroundColor',[1 0 0]);
  109. end
  110. % Create textbox
  111. if(A(3))
  112. annotation(figure1,'textbox',...
  113. [0.287427606177606 0.513812154696132 0.0546332046332053 0.115706129965801],...
  114. 'String',{'A2'},...
  115. 'FitBoxToText','off',...
  116. 'BackgroundColor',[1 1 0]);
  117. else
  118. annotation(figure1,'textbox',...
  119. [0.287427606177606 0.513812154696132 0.0546332046332053 0.115706129965801],...
  120. 'String',{'A2'},...
  121. 'FitBoxToText','off',...
  122. 'BackgroundColor',[1 1 0]);
  123. end
  124. % Create textbox
  125. if(A(4)==1)
  126. annotation(figure1,'textbox',...
  127. [0.438610038610041 0.599447513812153 0.0546332046332055 0.115706129965801],...
  128. 'String',{'A4'},...
  129. 'FitBoxToText','off',...
  130. 'BackgroundColor',[1 1 0]);
  131. else
  132. annotation(figure1,'textbox',...
  133. [0.438610038610041 0.599447513812153 0.0546332046332055 0.115706129965801],...
  134. 'String',{'A4'},...
  135. 'FitBoxToText','off',...
  136. 'BackgroundColor',[1 0 0]);
  137. end
  138. % Create textbox
  139. if(A(5)==1)
  140. annotation(figure1,'textbox',...
  141. [0.347393822393823 0.290055248618783 0.0546332046332055 0.115706129965801],...
  142. 'String',{'A5'},...
  143. 'FitBoxToText','off',...
  144. 'BackgroundColor',[1 1 0]);
  145. else
  146. annotation(figure1,'textbox',...
  147. [0.347393822393823 0.290055248618783 0.0546332046332055 0.115706129965801],...
  148. 'String',{'A5'},...
  149. 'FitBoxToText','off',...
  150. 'BackgroundColor',[1 0 0]);
  151. end
  152. % Create textbox
  153. if(A(6)==1)
  154. annotation(figure1,'textbox',...
  155. [0.541650579150581 0.417127071823203 0.0546332046332055 0.115706129965801],...
  156. 'String',{'A6'},...
  157. 'FitBoxToText','off',...
  158. 'BackgroundColor',[1 1 0]);
  159. else
  160. annotation(figure1,'textbox',...
  161. [0.541650579150581 0.417127071823203 0.0546332046332055 0.115706129965801],...
  162. 'String',{'A6'},...
  163. 'FitBoxToText','off',...
  164. 'BackgroundColor',[1 0 0]);
  165. end
  166.  
  167.  
  168. axis off;
  169. if A(1) == 1 && A(2) == 1 && A(4) == 1 && A(6) == 1
  170. title('Sistemul functioneaza');
  171. else if A(1) == 1 && A(3) == 1 && A(4) == 1 && A(6) == 1
  172. title('Sistemul functioneaza');
  173. else if A(1) == 1 && A(5) == 1 && A(6) == 1
  174. title('Sistemul functioneaza');
  175. else
  176. title('Sistemul nu functioneaza');
  177. end
  178. end
  179. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement