Filter löschen
Filter löschen

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 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

madhan ravi
madhan ravi am 23 Okt. 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 Kommentare
Peter Perkins
Peter Perkins am 31 Okt. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Numeric Types finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by