필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to put this information is a table?

조회 수: 1 (최근 30일)
Todd
Todd 2013년 12월 2일
마감: MATLAB Answer Bot 2021년 8월 20일
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
sixwwwwww
sixwwwwww 2013년 12월 2일
Values of which variables you want to put in a table? Can you specify?
Todd
Todd 2013년 12월 2일
편집: Todd 2013년 12월 2일
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

답변 (1개)

sixwwwwww
sixwwwwww 2013년 12월 2일
편집: sixwwwwww 2013년 12월 2일
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)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by