Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How to put this information is a table?

1 vue (au cours des 30 derniers jours)
Todd
Todd le 2 Déc 2013
Clôturé : MATLAB Answer Bot le 20 Août 2021
Hey I was wondering what command I would need to use to put all of this produced data in table or chart?
%Number 1 and 2
clear;
x0=[42;0;95];
extinct=0;
W=zeros(1,200);
for N= 1:10
F=2*rand(1);
for t=1:200;
W(t)=F;
A=[0 0 F; .6 0 0; 0 .75 .55];
x=(A^t)*x0;
if (sum(x)<1);
extinct=extinct+1;
break;
end
end
end
fprintf('#2 Number of extinction events for N=10 n=%d\n', extinct)
clear;
x0=[42;0;95];
extinct=0;
W=zeros(1,200);
for N= 1:20
F=2*rand(1);
for t=1:200;
W(t)=F;
A=[0 0 F; .6 0 0; 0 .75 .55];
x=(A^t)*x0;
if (sum(x)<1);
extinct=extinct+1;
break;
end
end
end
fprintf('#2 Number of extinction events for N=20 n=%d\n', extinct)
clear;
x0=[42;0;95];
extinct=0;
W=zeros(1,200);
for N= 1:50
F=2*rand(1);
for t=1:200;
W(t)=F;
A=[0 0 F; .6 0 0; 0 .75 .55];
x=(A^t)*x0;
if (sum(x)<1);
extinct=extinct+1;
break;
end
end
end
fprintf('#2 Number of extinction events for N=50 n=%d\n', extinct)
clear;
x0=[42;0;95];
extinct=0;
W=zeros(1,200);
for N= 1:100
F=2*rand(1);
for t=1:200;
W(t)=F;
A=[0 0 F; .6 0 0; 0 .75 .55];
x=(A^t)*x0;
if (sum(x)<1);
extinct=extinct+1;
break;
end
end
end
fprintf('#2 Number of extinction events for N=100 n=%d\n', extinct)
clear;
x0=[42;0;95];
extinct=0;
W=zeros(1,200);
for N= 1:200
F=2*rand(1);
for t=1:200;
W(t)=F;
A=[0 0 F; .6 0 0; 0 .75 .55];
x=(A^t)*x0;
if (sum(x)<1);
extinct=extinct+1;
break;
end
end
end
fprintf('#2 Number of extinction events for N=200 n=%d\n', extinct)
clear;
x0=[42;0;95];
extinct=0;
W=zeros(1,200);
for N= 1:500
F=2*rand(1);
for t=1:200;
W(t)=F;
A=[0 0 F; .6 0 0; 0 .75 .55];
x=(A^t)*x0;
if (sum(x)<1);
extinct=extinct+1;
break;
end
end
end
fprintf('#2 Number of extinction events for N=500 n=%d\n', extinct)
  2 commentaires
sixwwwwww
sixwwwwww le 2 Déc 2013
Values of which variables you want to put in a table? Can you specify?
Todd
Todd le 2 Déc 2013
Modifié(e) : Todd le 2 Déc 2013
The number of extinction events at each N range, I used the fprintf function to have matlab display them but I couldn't figure out how to make matlab put the resulting values into a table

Réponses (1)

sixwwwwww
sixwwwwww le 2 Déc 2013
Modifié(e) : sixwwwwww le 2 Déc 2013
Dear Todd, just do as follows:
count = 1;
%Number 1 and 2
x0=[42;0;95];
extinct=0;
W=zeros(1,200);
for N= 1:10
F=2*rand(1);
for t=1:200;
W(t)=F;
A=[0 0 F; .6 0 0; 0 .75 .55];
x=(A^t)*x0;
if (sum(x)<1);
extinct=extinct+1;
break;
end
end
Matrix(count, 1) = N;
Matrix(count, 2) = extinct;
count = count + 1;
end
fprintf('#2 Number of extinction events for N=10 n=%d\n', extinct)
x0=[42;0;95];
extinct=0;
W=zeros(1,200);
for N= 1:20
F=2*rand(1);
for t=1:200;
W(t)=F;
A=[0 0 F; .6 0 0; 0 .75 .55];
x=(A^t)*x0;
if (sum(x)<1);
extinct=extinct+1;
break;
end
end
Matrix(count, 1) = N;
Matrix(count, 2) = extinct;
count = count + 1;
end
fprintf('#2 Number of extinction events for N=20 n=%d\n', extinct)
x0=[42;0;95];
extinct=0;
W=zeros(1,200);
for N= 1:50
F=2*rand(1);
for t=1:200;
W(t)=F;
A=[0 0 F; .6 0 0; 0 .75 .55];
x=(A^t)*x0;
if (sum(x)<1);
extinct=extinct+1;
break;
end
end
Matrix(count, 1) = N;
Matrix(count, 2) = extinct;
count = count + 1;
end
fprintf('#2 Number of extinction events for N=50 n=%d\n', extinct)
x0=[42;0;95];
extinct=0;
W=zeros(1,200);
for N= 1:100
F=2*rand(1);
for t=1:200;
W(t)=F;
A=[0 0 F; .6 0 0; 0 .75 .55];
x=(A^t)*x0;
if (sum(x)<1);
extinct=extinct+1;
break;
end
end
Matrix(count, 1) = N;
Matrix(count, 2) = extinct;
count = count + 1;
end
fprintf('#2 Number of extinction events for N=100 n=%d\n', extinct)
x0=[42;0;95];
extinct=0;
W=zeros(1,200);
for N= 1:200
F=2*rand(1);
for t=1:200;
W(t)=F;
A=[0 0 F; .6 0 0; 0 .75 .55];
x=(A^t)*x0;
if (sum(x)<1);
extinct=extinct+1;
break;
end
end
Matrix(count, 1) = N;
Matrix(count, 2) = extinct;
count = count + 1;
end
fprintf('#2 Number of extinction events for N=200 n=%d\n', extinct)
x0=[42;0;95];
extinct=0;
W=zeros(1,200);
for N= 1:500
F=2*rand(1);
for t=1:200;
W(t)=F;
A=[0 0 F; .6 0 0; 0 .75 .55];
x=(A^t)*x0;
if (sum(x)<1);
extinct=extinct+1;
break;
end
end
Matrix(count, 1) = N;
Matrix(count, 2) = extinct;
count = count + 1;
end
fprintf('#2 Number of extinction events for N=500 n=%d\n', extinct)

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by