write a matlab program to find the summation of numbers greater than 5 only from 1 to 10 using while loop. (hint: if statement and break statement is nested). in matlab

Here is a matlab program that uses a while loop, if statement, and the break statement to find the summation of numbers greater than 5 from 1 to 10:

main.m
% Initialize variables
num = 1;
sum = 0;

% Start while loop
while num <= 10
    % Check if number is greater than 5
    if num > 5
        % Add number to sum
        sum = sum + num;
    end
    
    % Increment number
    num = num + 1;
    
    % Break out of loop if number exceeds 10
    if num > 10
        break;
    end
end

% Display the final sum
disp(sum);
369 chars
24 lines

This program starts with the number 1 and checks if it is greater than 5. If it is, it adds it to the sum. Then, it increments the number by 1 and checks if it exceeds 10. If it does, the program breaks out of the loop. The process continues until all numbers from 1 to 10 have been checked. Finally, the program displays the final sum.

Hope this helps!

gistlibby LogSnag