How can I save values in a matrix?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
mary bakali
am 29 Mai 2015
Beantwortet: Ingrid
am 29 Mai 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 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!