Borrar filtros
Borrar filtros

use function for and if via matlap

2 visualizaciones (últimos 30 días)
Musaed
Musaed el 6 de Mayo de 2023
Respondida: Musaed el 6 de Mayo de 2023
50 60 -2 -15 100
1- find the sum of a set of five different numbers
2- find the sum of negative numbers
3-find how many numbers are more than 40 and less than 90
  1 comentario
Image Analyst
Image Analyst el 6 de Mayo de 2023
To learn such very fundamental concepts, invest 2 hours of your time here:

Iniciar sesión para comentar.

Respuesta aceptada

Atsushi Ueno
Atsushi Ueno el 6 de Mayo de 2023
nms = [50 60 -2 -15 100];
sum(nms) % 1- find the sum of a set of five different numbers
ans = 193
sum(nms(nms < 0)) % 2- find the sum of negative numbers
ans = -17
sum(nms > 40 & nms < 90) % 3-find how many numbers are more than 40 and less than 90
ans = 2

Más respuestas (1)

Musaed
Musaed el 6 de Mayo de 2023
%[50 60 -2 -15 100]
sum=0;
for x=1:5
z=input('enter#')
sum=sum+z;
end
disp('sum=')
disp(sum)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by