A = pi; b = [4 3 77 4 2 9 0]; test = 'sample text'; whos save testVariables.mat clear all whos |
whos ls *.mat load testVariables.mat whos A b test |
whos ls *.mat delete testVariables.mat ls *.mat |
A = pi; b = [4 3 77 4 2 9 0]; test = 'sample text'; whos save testVariables.mat A test clear all whos |
ls *.mat load testVariables.mat whos A b test |
b = [4 3 77 4 2 9 0]; save testVariables.mat b -append whos A b test |
fileID = fopen('testFile.m'); tline = fgetl(fileID); fclose(fileID) |
fid = fopen('fgetl.m'); tline = fgetl(fid); while ischar(tline) disp(tline) tline = fgetl(fid); end fclose(fid); |
fopen('filename','permission') 'r' - read (default) 'r+' - read and write 'w' - write/overwrite 'w+' - read and overwrite 'a' - write to end of file (append) 'a+' - read and write to end of file |
fileID = fopen('testFile.m','w'); tline = fgetl(fileID); fclose(fileID) tline |
fileID = fopen('nine.bin','w'); fwrite(fileID,[1:9]); fclose(fileID); |
fileID = fopen('nine.bin'); A = fread(fileID) |
filename = 'testdata.xlsx'; A = [12.7 5.02 -98 63.9 0 -.2 56]; xlswrite(filename,A) |
filename = 'testdata.xlsx'; A = {'Time','Temperature'; 12,98; 13,99; 14,97}; sheet = 2; xlRange = 'E1'; xlswrite(filename,A,sheet,xlRange) |
values = {1, 2, 3 ; 4, 5, 'x' ; 7, 8, 9}; headers = {'First','Second','Third'}; xlswrite('myExample.xlsx',[headers; values]); filename = 'myExample.xlsx'; A = xlsread(filename) |
filename = 'myExample.xlsx'; sheet = 1; xlRange = 'B2:C3'; subsetA = xlsread(filename,sheet,xlRange) |
filename = 'myExample.xlsx'; columnB = xlsread(filename,'B:B') |
isvector() | isscalar() |
isstring() | isnumeric() |
islogical() | isfloat() |
isletter() | ismatrix() |
isdatetime() | ischar() |
isempty() | isundefined() |
A = imread('ngc6543a.jpg'); image(A) A(1,1,:) A(1,1) = 10; A(1,1,:) A(1,1,:) = 255 image(A) |
A = rand(500); imwrite(A,'myGray.png') |
load clown.mat imwrite(X,map,'myclown.png') |
load clown.mat newmap = copper(81); imwrite(X,newmap,'copperclown.png'); |
C = [0 2 4 6; 8 10 12 14; 16 18 20 22]; image(C) colorbar |
A = imread('ngc6543a.jpg'); image(A) A(250:350,250:350) = 0; image(A) |
function c = addme(a,b) switch nargin case 2 c = a + b; case 1 c = a + a; otherwise c = 0; end |
function [dif,absdif] = subtract(y,x) dif = y - x; if nargout > 1 disp('Calculating absolute value') absdif = abs(dif); end |
"I just want you to know that, when we talk about war, we're really talking about peace." |
"A zebra does not change its spots." |