Advertisement
obediah

Untitled

Apr 26th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. %% Problem 1
  2.  
  3. clear;clc;
  4.  
  5. s = input('Enter the size of the square')
  6.  
  7.  
  8. while s <= 0 | s > 26
  9. disp('The size must be between 1 and 26')
  10. s = input('Try again: enter the size of the square')
  11. end
  12.  
  13. a = input('Enter a single character used for the background', 's')
  14. Vec1 = double(a);
  15.  
  16. while length(Vec1) > 1
  17. disp('Enter only a single printable character!')
  18. a = input('Enter the background character again', 's')
  19. Vec1 = double(a)
  20. end
  21.  
  22. MTX(s,s) = 0
  23.  
  24. for i = 1:s
  25. for j = 1:s
  26. if i == j
  27. MTX(i,j) = double('A') - j + s
  28. elseif i > j
  29. MTX(i,j) = a
  30. end
  31. end
  32. end
  33.  
  34. char(MTX)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement