You are on page 1of 1

#nos mand a practicar un poco con ifelse o while

Creando bucles con if.else como ejercicio


A=zeros(5,8);
for i=1:5
for j=1:8
if (rem(i,2)==0)|(rem(j,2)==0)
A(i,j)=sqrt(i+j);
else
A(i,j)=i^2+j^2;
end
end
end

dando como respuesta

>> alallala

A=

2.0000

1.7321 10.0000

1.7321

2.0000

10.0000
2.2361
26.0000

2.2361

2.2361 18.0000
2.4495

2.6458

2.6458 34.0000

2.2361 26.0000
2.4495

2.6458

2.6458 34.0000
2.8284

3.0000

3.0000 50.0000

2.6458 50.0000
2.8284

3.0000

3.0000
3.1623

3.0000 58.0000
3.1623

3.3166

3.3166

3.4641

3.3166 74.0000

3.6056

You might also like