Info

This question is closed. Reopen it to edit or answer.

reading file and writing in matrix

1 view (last 30 days)
Simon219
Simon219 on 15 May 2020
Closed: MATLAB Answer Bot on 20 Aug 2021
I have got a data file with number density at corresponding radius inside. Part of the code is shown below: (the first column is the number density, the second column is the radial distance from the origin.)
0.000000 38.817338
0.000802 38.990518
0.000000 39.163698
0.000788 39.336878
0.000782 39.510058
0.000000 39.683238
0.000000 39.856419
0.000761 40.029599
0.000000 40.202779
There are many other zeros and non-zeros data. And I want to make it to be the initial condition of some function u which satisfies the diffusion equation in cartesian coordinate. For the part of diffusion equation, I have set a set of for loop to initialize u.
u=zeros(m,m,m,r);
for l=1:r
for k=1:m
for j=1:m
for i=1:m
if (i==1) && (j==1) && (k==1)
u(i,j,k,l)=(u1+u4+u5)/3;
...
elseif (k==m)
u(i,j,k,l)=u2;
else
u(i,j,k,l)=u7
end
end
end
end
end
where l ranging from 1 to r indicates the time coordinate, u7 is the original constant value initial condition applied to the whole system.
My problem is how could I fit the set of number density data in the initial condition.

Answers (0)

Community Treasure Hunt

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

Start Hunting!