Borrar filtros
Borrar filtros

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 visualizaciones (últimos 30 días)
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

Respuesta aceptada

madhan ravi
madhan ravi el 23 de Oct. de 2018
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 comentarios
Peter Perkins
Peter Perkins el 31 de Oct. de 2018
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Numeric Types en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by