Question: Given the following MATLAB code, convert the nested for loops to nested while loops. Make sure the two coding examples produce the same results, in
Given the following MATLAB code, convert the nested for loops to nested while loops. Make sure the two coding examples produce the same results, in content and format. A = [7, 5; 3, 9; 1, 2); row = 3; % it's best to use variables instead =2; % of fixed numbers sum = 0; for (i = 1:row) % loop over rows for (j = 1:col) % loop over columns sum = sum + A(i, j); end sum Create a coding sequence that will accept as prompted input, one field -month Name, this is a string value. Now create a branching set of code, using else if clauses, which will assign the number of days in the month. Use the following information to establish the month day relationship: Feb: 28 Apr, Jun, Sep, Nov: 30 Jan, Mar, May, Jul, Aug, Oct, Dec: 31 the output stream should look like: "Jan has 31 days". Use either dips or f print f function to generate the output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
