How can I save values in a matrix?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
mary bakali
el 29 de Mayo de 2015
Respondida: Ingrid
el 29 de Mayo de 2015
I was asked to create a simulation of an airflight, in three steps:(The problem is in the third step, the first two functions work properly. However, I'm including them for better understandment)
Step 1:
function failure= SimEngine(x)
n=rand(1,1);
if (n<x)
failure=true;
else failure=false;
end
end
Step 2:
function crush= SimAirplane(a,x)
m=0;
for i=1:a
A=SimEngine(x);
if (A==1)
m=m+1;
end
end
if (m>(a/2))
crush=true;
else
crush=false;
end
end
So in the third step, I was asked to use the two function above and create a function with three variables.
function y = SimNAirplanes(b,a,x)
y=[];
k=0;
for i=1:1:b
s=SimAirplane(a,x)
if (s==1)
k=k+1;
end
end
end
When using the third function, e.g. SimNAirplane(2,2,0.5) this is displayed:
s=0
s=1
s=0
My question is what command can I use, so that Matlab displays this: y=[0;1;0]?
0 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Multidimensional Arrays en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!