clear all;
clc;
num_pts = 10;
Afull = zeros(num_pts,num_pts);
Afull(1,1) = 1;
Afull(num_pts,num_pts) = 1;
for i = 2:(num_pts-1) %sum over interior points
Afull(i,i) = 2;
Afull(i,i-1) = -1;
Afull(i,i+1) = -1;
end
b = linspace(0,1,num_pts)';
x = Afull/b;
whos;
% Visualize sparsity pattern
spy(Afull);
sparse(Afull)
% save mem_store1.mat;
% pause;
% clear all;
% whos;
% ls *.mat
% pause;
% load mem_store1.mat;
% whos;
% pause;
% delete mem_store1.mat
% ls *.mat
%
% pwd
% cd ..
% pwd
% ls
% save store1.dat Afull -ascii;
% type store1.dat
% % load store1.dat
%
% delete store1.dat;
% save store1.dat Afull -ascii -double;
% type store1.dat
%file operation write b(i) into test_io.dat
FID_out = fopen('test_io.dat','w');
ls
for i = 1:length(b)
fprintf(FID_out,'%10.6f /n',b(i));
end
fclose(FID_out);
disp('Contents of test_io.dat:');
type test_io.dat;
% read the file into b_new
FID_in = fopen('test_io.dat');
b_new = linspace(0,0,num_pts)';
for i = 1:num_pts
b_new(i) = fscanf(FID_in,'%f',1);
end
b_new;
% read file to x_new
FID_in = fopen('test_io.dat');
x_new = linspace(0,0,num_pts)';
x_new = fscanf(FID_in,'%f',num_pts);
x_new;