How to extract values to create a table on excel?

1 view (last 30 days)
This is my code but I'm unsure of how to extract the data that I get from the graph. I want to extract this data so I can view it on excel. Any suggestion of how to do it?
function steadyheat_jacob
%-------------------------------------------------------------------------
% Heat diffusion equation in a rectangular fin using
% Jacob iterative solver
%--------------------------------------------------------------------------
% physical values
lx=0.012;
ly=0.0012;
Tb=85;
h=100;
k=180;
Tinf=20;
%--------------------------------------------------------------------------
% numerical domain
mx=50;
my=20;
nx=mx+1;
ny=my+1;
dx=lx/mx; dy=ly/my;
beta2=(dx*dx)/(dy*dy);
convt=h*dx*dx/(k*dy);
x=linspace(0,lx,nx);
y=linspace(0,ly,ny);
%--------------------------------------------------------------------------
% allocate u and initize it to be u_wall
T=zeros(nx,ny);
T(:,:)=Tb;
%--------------------------------------------------------------------------
% const boundary conditions
%left b.c.
T(1,:)=Tb;
%--------------------------------------------------------------------------
Tnew=T;
%set(gca,'Tlim',[0 Tb]);
%surf(x,y,T'); shading interp;
%fprintf('Pressing any key to start...\n');
%pause;
err_tol=0.0001; err=2*err_tol;
iter=0;
%--------------------------------------------------------------------------
% main loop
while (err>err_tol) && iter<200000
%% i=1 is the left boundary, T=Tb
for i=2:mx
j=1; % bottom boundary
Tnew(i,j)=(T(i-1,j)+ T(i+1,j)+2*beta2*T(i,j+1)+2*convt*Tinf)...
/(2*(1+beta2+convt));
for j=2:my % iternal nodes
Tnew(i,j)=(T(i-1,j)+T(i+1,j)+beta2*T(i,j-1)+beta2*T(i,j+1))...
/(2*(1+beta2));
end
j=my+1; % top boundary
Tnew(i,j)=(T(i-1,j)+T(i+1,j)+beta2*T(i,j-1)*2+2*convt*Tinf)...
/(2*(1+beta2+convt));
end
i=mx+1; % right boundary
j=1; % bottom-right corner node
Tnew(i,j)=(T(i-1,j)+ T(i-1,j)+2*beta2*T(i,j+1)+2*convt*Tinf)...
/(2*(1+beta2+convt));
for j=2:my % righ boundary
Tnew(i,j)=(T(i-1,j)+T(i-1,j)+beta2*T(i,j-1)+beta2*T(i,j+1))...
/(2*(1+beta2));
end
j=my+1; % top-right corner node
Tnew(i,j)=(T(i-1,j)+ T(i-1,j)+beta2*T(i,j-1)*2+2*convt*Tinf)...
/(2*(1+beta2+convt));
err=sum(sum(abs(Tnew-T)));
T=Tnew;
iter=iter+1;
end
%--------------------------------------------------------------------------
% output results
fprintf('\nIter=%d, sum error=%f\n', iter,err);
set(gca,'zlim',[0 Tb]);
surf(x,y,T');shading interp;
fileID=fopen('fin.txt','w');
for j=1:ny %size(T,1)
fprintf(fileID, '%f\t', T(:,j));
fprintf(fileID,'\n');
end
fclose(fileID);
%-------------------------------------------------------------------------

Answers (1)

per isakson
per isakson on 6 Mar 2019
Edited: per isakson on 6 Mar 2019
Try
>> [x,y,T] = steadyheat_jacob()
where
function [x,y,T] = steadyheat_jacob()
%-------------------------------------------------------------------------
% Heat diffusion equation in a rectangular fin using
% Jacob iterative solver
%--------------------------------------------------------------------------
...
end
Then you can inspect x, y, T with the variable editor or export them to Excel
Or I missed your question

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!