필터 지우기
필터 지우기

Hi i'm trying to crate a table colums of table will be col1 col2 col3 col4 and col5. I have to store all iteration steps in a matrix. How can i do that?

조회 수: 3 (최근 30일)
clear;
clc;
syms m ;
h=6.626e-34;
k=1.3807*10^-3;
C2=14388;
C0=2.998e8;
C1=2*pi*h*C0^2;
for nlamdaT=1000:100:50000
eta=C2/nlamdaT;
fun=(6+(6*(eta*m))+(3*((m*eta).^2))+(((m*eta)^3)))/(exp(m*eta)*(m^4));
S=symsum(fun,m,1,inf);
f=(15/pi^4)*S;
% make the columns of table
col1=nlamdaT';
col2=(1/(nlamdaT))*10.^4;
col3=10^24*C1./((nlamdaT).^5.*(exp((C2./nlamdaT))-1));
col4=10^20*C1./((nlamdaT).^3.*(exp((C2./nlamdaT))-1));
col5=double(f);
nlamdaT=nlamdaT+10;
% create the table
T=table(col1,col2,col3,col4,col5)
end

채택된 답변

madhan ravi
madhan ravi 2018년 10월 23일
clear; clc; syms m ;
h=6.626e-34;
k=1.3807*10^-3;
C2=14388;
C0=2.998e8;
C1=2*pi*h*C0^2;
ctr=1;
T=table;
for nlamdaT=1000:100:50000
eta=C2/nlamdaT;
fun=(6+(6*(eta*m))+(3*((m*eta).^2))+(((m*eta)^3)))/(exp(m*eta)*(m^4));
S=symsum(fun,m,1,inf); f=(15/pi^4)*S; % make the columns of table
col1(ctr)=nlamdaT';
col2(ctr)=(1/(nlamdaT))*10.^4;
col3(ctr)=10^24*C1./((nlamdaT).^5.*(exp((C2./nlamdaT))-1));
col4(ctr)=10^20*C1./((nlamdaT).^3.*(exp((C2./nlamdaT))-1));
col5(ctr)=double(f);
% T=nlamdaT+10; % NO NEEDED
x=table(col1(ctr),col2(ctr),col3(ctr),col4(ctr),col5(ctr));
T = [T; x];
ctr = ctr+1;
end
T
  댓글 수: 5
Peter Perkins
Peter Perkins 2018년 10월 31일
If I am reading this code correctly, take these two lines
x=table(col1(ctr),col2(ctr),col3(ctr),col4(ctr),col5(ctr));
T = [T; x];
Out of the loop, and put this line
T = table(col1,col2,col3,col4,col5);
after the loop.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by