clear ifirst=2 % fist~=1 - without files construction IDpossible=[1,2,3] % if ifirst==1 %% All possible situations for file creations: % upload the data ID=1 (excel file exists), % ID=2 (binary file need create in folder one time and show how to upload), % ID=3 (text file need create in folder one time and show how to upload) IDpossible=[1,2,3] % all cases for ID= IDpossible if ID==1 % the first way: upload the Excel table A=xlsread('design.xlsx') % [numeric,text,all_as_cell] = xlsread(FileName) A(isnan(A))=0 % how to create binary file DataBinary.mat, containig matrix A: save DataBinary A % optional, it will be required for the first time if the DataBinary.mat doesn't exist elseif ID==2 load DataBinary else % how to create text file with numeric data A with known size: % % optional, it will be required for the first time if the A.txt doesn't exist if exist('A')==1 % it means, that variable named A exists in workspace, you can see all options of exist in help: select function exist and press the F1 button [nrow,ncolumn]=size(A) fA=fopen('A.txt','w') % text files is created fprintf(fA,'%d\n',A) % to the current folder fclose(fA) end % we can use A.txt (in current folder) fa=fopen('A.txt','r') A= fscanf(fa,'%d') % read as one column A= reshape(A,nrow,ncolumn) % change the shape vector-column to real matrix size fclose(fa) end end %______ ifirst=2 __________________________ else % ifirst=2, f.e. A=xlsread('design.xlsx') % [numeric,text,all_as_cell] = xlsread(FileName) A(isnan(A))=0 end %if ifirst==1 [m,n]=size(A) B=fliplr(A) % watch function flipud too (Help) heart=[A,zeros(m,1),B] % the original matrix + a column of zeros + a left-to-right flip of the original matrix [m,n]=size(heart) subplot(2,2,1), sgtitle('heart design') spy(heart, 'r.',20) [i,j]=find(heart==2) heart(i(1)+1,j(1)+1)=3 title('half desing - fliplr') subplot(2,2,2) spy(heart, 'r.',20), hold on spy(heart==3, 'green',20) title('->odd columns (add)' ) subplot(2,2,3) heart=[heart;zeros(1,n)] spy(heart, 'r.',20), title('add one row (the last)' ) heart(m+1,j(1)+1)=4 subplot(2,2,4), spy(heart, 'r.',20), hold on spy(heart==4, 'black',20) title('other color if heart==4' ) disp('That''s all')