Saving plot in a directory

Clear figure

visualizing amtrix

A = magic(5)
imagesc(A)% draw a 5*5 grids of colors and colors are related to the values of matrix.
imagesc(A) , colorbar % add bar to the image

scripting in Octave

adding a folder to path

addpath('/scr/myscripts')

control statement

for

for i=1:10;
v(i) = 2^i ;
end;

while & if

i=1;
while i<=5,
v(i)=20;
i=i+1;
end;
%%%%% OR
i=1;
while true,
v(i)=20;
i=i+1;
if i==6,
break;
end;
end;
%%%%%%
if v(1)==20,
disp('The first one is equal to twenty');
elseif v(2)==5,
disp('The second one is equal to five');
else,
disp('Neither v(1) ==20 or v(2)==5')

defining function

like matlab, write function into a ".m" file.

function [y1 , y2]= squareandcube(x)
y1=x^2;
y2=x^3;

to call the function just cd to that directory and call that function no file calling in needed!!!