Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

How to put this information is a table?

1 view (last 30 days)
Todd
Todd on 2 Dec 2013
Closed: MATLAB Answer Bot on 20 Aug 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 Comments
sixwwwwww
sixwwwwww on 2 Dec 2013
Values of which variables you want to put in a table? Can you specify?
Todd
Todd on 2 Dec 2013
Edited: Todd on 2 Dec 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

Answers (1)

sixwwwwww
sixwwwwww on 2 Dec 2013
Edited: sixwwwwww on 2 Dec 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)

This question is closed.

Tags

Community Treasure Hunt

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

Start Hunting!