Use Matlab to write a program that creates a Matrix call it

Use Matlab to write a program that creates a Matrix (call it data) of size (4, 3) and set each element in the matrix as the sum of its index numbers (e.g., element 3, 2 will be equal to 5) using \"for loop\". Also export this Matrix to an Excel file (call it data.xlsx).

Solution

data = zeros(4,3)

for i = 1:4
   for j = 1:3
       data(i,j) = i + j;
   end
end

disp(data);

filename = \'data.xlsx\';
writetable(data,filename,\'Sheet\',1,\'Range\',\'D1\')

 Use Matlab to write a program that creates a Matrix (call it data) of size (4, 3) and set each element in the matrix as the sum of its index numbers (e.g., ele

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site