Advertisement
Guest User

Untitled

a guest
Jun 21st, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1.  
  2. function choinka(n)
  3. k=0;
  4. for i=1:n
  5. for j=1:i
  6. k=k+1;
  7. x(k)=-j;
  8. y(k)=i;
  9. endfor
  10. endfor
  11. plot(x,y,'k*')
  12. endfunction
  13.  
  14.  
  15.  
  16.  
  17. output_precision(4)
  18.  
  19. z dolu lewo gora prawo nad:
  20.  
  21. function [suma] = funmacierz (A)
  22. sum = 0;
  23. n = rows(A);
  24. m = columns(A);
  25. for i=1:n-1
  26. A(i,m)=A(i,m-1);
  27. sum = sum + A(i,m);
  28. m = m - 1;
  29. endfor
  30. suma = sum;
  31.  
  32. endfunction
  33.  
  34. lewo gora prawo dol nad:
  35.  
  36. function [suma]=funmacierz(A)
  37. sum=0;
  38. for i=1:rows(A)-1
  39. A(i,i)=A(i,i+1);
  40. sum=sum+A(i,i);
  41.  
  42. endfor
  43.  
  44. suma=sum;
  45. endfunction
  46.  
  47. z lewo gora prawo dol pod:
  48.  
  49. function [suma]=lolo(A)
  50. sum=0;
  51. for i=1:rows(A)-1
  52. A(i,i)=A(i+1,i);
  53. sum=sum+A(i,i);
  54. endfor
  55.  
  56. suma=sum;
  57. endfunction
  58.  
  59. z lewo dol prawo gora pod:
  60.  
  61. function [suma] = lolo (A)
  62. sum = 0;
  63. n = rows(A);
  64. m = columns(A);
  65. for i=1:n-1
  66. A(i,m)=A(i+1,m);
  67. sum = sum + A(i,m);
  68. m = m - 1;
  69. endfor
  70. suma = sum;
  71.  
  72. endfunction
  73.  
  74.  
  75.  
  76. polowa macierzy
  77.  
  78. function [suma] = coja (A)
  79. n = rows(A);
  80. c = (round(n/2));
  81. m = columns(A);
  82. sum = 0;
  83. for i=1:c
  84. for j=1:m
  85. sum = sum + A(i,j);
  86. endfor
  87. endfor
  88. suma = sum;
  89.  
  90. endfunction
  91.  
  92.  
  93.  
  94. nad przekatna:
  95.  
  96. n = 5;
  97. A = magic(n)
  98. suma = 0;
  99. for i=1:n
  100. for j=i+1:n
  101. suma = suma + A(j,i);
  102. endfor
  103. endfor
  104. suma
  105.  
  106. http://pastebin.com/RneMMz48
  107.  
  108. http://pastebin.com/cYsKhRgJ
  109.  
  110. http://pastebin.com/9Dw1TNuU - diament
  111.  
  112.  
  113. http://pastebin.com/g0tBJRGY - lepoiej nie pytac
  114.  
  115.  
  116. suma=0; %sc=1;
  117. n=0; %indeks
  118. sc=1;
  119. while (sc>= 0.001) ##jak przekroczy to nie spelniony, ale jest dodany do n
  120. n=n+1;
  121. sc=1/(n*sqrt(n));
  122. suma=suma+sc;
  123. endwhile;
  124. disp("indeks najwiekszego wyrazu mniejszego od 1/1000: ");
  125. disp(n);
  126.  
  127. function [k]=palindrom(L)
  128. k=0;
  129. n=0;
  130. x=0;
  131. s=size(L);
  132. s=s(2);
  133. for i=1:s
  134. if L(i)==L(s-x)
  135. n=n+1;
  136. endif;
  137. x=x+1;
  138. endfor;
  139. if n==s
  140. k=1;
  141. disp("To jest palindrom")
  142. endif;
  143. endfunction;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement