I am kind of new at creating matlab loops and just needed help on this question.
Use loops to create a m x n Matrix named Mat in which the value of each element is the sum of its row number and its column number divided by the square of its column number. For example, the value of element (2,3) is (2+3)/3^2.
m is the number of rows and n is the number of columns. Code has already been provided to assign m and n psuedo-random integer values between 5 and 15. Suppress all statements inside the loop and use a disp command to output the final matrix after the loop.
I am given this:
m = randi([5,15]);
n = randi([5,15]);
%Create a m x n matrix using for loop.
%The elements has to be (row number+column number)/(square of column number)
I have created this and idk how to create it into a matrix.
Mat = [m,n]
[R,C] = size(Mat)
for row = 1:R
for col = 1:C
Mat(row,col) = Mat((R+C)/C^2,(C+R)/C^2)
end
end
disp(Mat)