Take two inputs from the user and build following square-matrix Example run: Siz
ID: 3565105 • Letter: T
Question
Take two inputs from the user and build following square-matrix
Example run:
Size of the square-matrix: 11
Cutting factor: 8
Output:
Does anyone know how to go about making a script on how to solve this? I've tried but I haven't been able to get this. An explanation would be most appreciated. Thank you.
Take two inputs from the user and build following square-matrix Example run: Size of the square-matrix: 11 Cutting factor: 8 Output: Does anyone know how to go about making a script on how to solve this? I've tried but I haven't been able to get this. An explanation would be most appreciated. Thank you.Explanation / Answer
%Take two inputs from the user and build following square-matrix
row = input('Size of the square-matrix: ');
fact = input('Cutting factor: ');
mat = [];
for i=1:row
for j=1:row
if i+j <= (fact+1)
mat(i,j) = 0;
else
mat(i,j) = 1;
end
end
end
mat
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.