Sunteți pe pagina 1din 10

sind(0.

0)
quit
# Octave 3.4.3, Wed Feb 15 17:25:53 2012 South Africa Standard Time <unknown@unk
nown>
ver
# Octave 3.6.0, Thu Feb 16 09:29:32 2012 South Africa Standard Time <unknown@Use
r-PC>
ver
# Octave 3.6.0, Thu Feb 16 09:42:44 2012 South Africa Standard Time <unknown@Use
r-PC>
who
why
disp (stdout, "The value of pi is:"), disp (stdout, pi)
disp (stdout, "The value of pi is:")
disp(stdout, "The value of pi is:"), disp(stdout, pi)
disp(stdout, pi)
disp(pi)
disp("The value of pi is:")
disp("The value of pi is:"pi)
disp("The value of pi is:" pi)
disp("The value of pi is:"), pi
disp("The value of pi is:"), disp(pi)
fflush
fflush(fid)
input("Pick a number, any number! ")
sf
input("Pick a number, any number! ")
20
fflush(stdout)
disp(stdout, "The value of pi is:"), disp(stdout, pi)
pct = 37;
filename = "foo.txt";
printf ("Processing of `%s' is %d%% finished.\nPlease be patient.\n",
filename, pct)
aa=input('what is your name? ' )
rrr
aa=input('what is your name? ','s' )
fff
bb=input('what is your age?')
60
printf('your name is,' aa, 'and your age is' num2str(age) 'years old')
printf("your name is," aa, "and your age is" num2str(age) "years old")
printf("your name is," %aa, "and your age is" num2str(age) "years old")
printf("your name is," %aa, "and your age is" num2str(age) "years old")
printf("your name is %aa, and your age is num2str(age) years old")
printf("your name is %aa")
printf("your name is %bb")
bb
printf("your name is %bb%")
printf("your name is %d%")
printf("your name is %d")
printf("your name is dd")
printf("your name is bb")
printf("your name is %d")
closeall
clear all
clc
bb=input('what is your age?')
60
aa=input("what is your name", 's')

sgfasg
printf("your name is %d")
printf("your name is %d%")
printf("your name is %s and you are %d% years old",aa,bb)
printf("your name is %s and you are %d% years old",aa, bb)
help printf
printf("your name is %s and you are years old",aa)
printf("your name is %s and you are %d years old",aa, bb)
printf("your name is %s and you are %d years old",aa, bb);
# Octave 3.6.0, Fri Feb 17 16:15:12 2012 South Africa Standard Time
r-PC>
doc
doc introduction
doc
exit
# Octave 3.6.0, Sat Feb 18 12:04:24 2012 South Africa Standard Time
r-PC>
pct = 101.23;
name = "john phiri";
printf('my name is %s and I am %d years old',name,pct)
printf('my name is %s and I am %d years old',name,pct\n)
printf('my name is %s and I am %d years old',\n name,pct\n)
printf('my name is %s and I am %d years old",name,pct)
printf('my name is %s and I am %d y
# Octave 3.6.0, Mon Feb 20 10:53:26 2012 South Africa Standard Time
r-PC>
printf("my name is %s and I am %d years old",name,pct)
age = 101.23;
name = "john phiri";
printf("my name is %s and I am %d years old",name,pct)
printf("my name is %s and I am %d years old",name,age)
printf("my name is %s and I am %d years old",name,age)
printf("my name is %s and I am %d years old",name,pct)[B
disp("my name is" name, "and I am num2str(age) "years old")
disp(["my name is" name, "and I am num2str(age) "years old"])
disp(["my name is" name, "and I am num2str(age)"])
disp(["my name is" name, "and I am" num2str(age) "years old"])
disp(["my name is" name, "and I am" num2str(age) "years old"])
doc
doc getting started
doc
printf('my name is %s and I am %d years old\n',name,age)
printf('my name is %s and I am %d years old\n',name,age)
printf('my name is %s and I am %d years old\n',name,age)
printf('my name is %s and I am %d years old\n',name,age)
printf('my name is %s and I am %d years old\n',name,age)
printf("my name is %s and I am %f years old\n",name,age)
printf("my name is %s and I am %f years old\n",name,age)
edit
edit
printf('my name is %s and I am %o years old\n", name,age)
printf('my name is %s and I am %o years old\n", name,age)
printf('my name is %s and I am %o years old\n', name,age)
printf('my name is %s and I am %u years old\n', name,age)
printf('my name is %s and I am %x years old\n', name,age)
printf('my name is %s and I am %c years old\n', name,age)
exit
# Octave 3.6.0, Mon Feb 20 16:52:26 2012 South Africa Standard Time
r-PC>
sind(0)

<unknown@Use

<unknown@Use

<unknown@Use

<unknown@Use

nargin
nargin(sind)
sind(1,2,3)
sind([1 2 3])
nargin
nargin(sind)
help nargin
sind([1 2 3])
sind([1 2 3])
help rgb2ind
elseif (nargin == 3)
[a1, a2] = rgb2ind (a1, a2, a3);
colormap (a2);
endif
[a1, a2] = rgb2ind(a1, a2, a3);
help div
help rem
oddeven
201
oddeven
200
oddeven
201
201
oddeven
2
num = 103;
div = 2;
while (1)
if (rem (num, div) == 0)
printf ("Smallest divisor of %d is %d\n", num, div);
break;
endif
div++;
if (div*div > num)
printf ("%d is prime\n", num);
break;
endif
endwhile
rem(num,div)
num
div
help ==
oddeven
40
oddeven
20
oddeven
21
oddeven
3
oddeven
20
oddeven
21
oddeven
3
oddeven
2
oddeven

3
# Octave 3.6.0, Fri Feb 24 08:15:41 2012 South Africa Standard Time <unknown@Use
r-PC>
eye (2, 4)
i
j
help common_size
common_size([2 3 4 5 6])
error common_size([2 3 4 5 6])
error = common_size([2 3 4 5 6])
[error,a,b] = common_size([2 3 4 5 6],7)
[error,a,b] = common_size([2 2 2 2 2],7)
[error,a,b] = common_size([2 2 2 2 2],2)
[1 1]==[3 4]
[1 1 1 1]==[1 1 1 1]
[1 1 1 1]==[1 1 1 2]
[1]==[1 1 1 2]
[1, 0; 0, 1] & [1, 0; 2, 3]
[1, 0; 0, 1] | [1, 0; 2, 3]
[1 1 1 1]&&[1 1 1 2]
[1 1 1 1]&&[1 1 1 1]
[1 1 1 1]&&[1 2 4 5]
[1 1 1 1]&&[6 2 4 5]
1==2
1==2==3
1==2==3==4
1==1==3==4
1==1==1==4
1==1==1==1
1==3==3==3
3==3==3==3
3==3
3==3==3
3=3=3
help arg
disp('I''ve guessed a number between 0 and 100.');
disp('I'''ve guessed a number between 0 and 100.');
disp(['I'''ve guessed a number between 0 and 100.']);
disp(['I''ve guessed a number between 0 and 100.']);
a=1
b=2
c=3
d=3
a&b
a&b$c
a&b&c
c&d
c&&d
if (a==b & b==c)
disp('0');
else
comparison
comparison
dir
q
quit
exit
# Octave 3.6.0, Fri Feb 24 11:48:52 2012 South Africa Standard Time <unknown@Use
r-PC>
comparison

comparison
comparison
comparison
comparison
comparison
comparison
comparison
comparison
comparison
comparison
(a==b & b==c & c==d & d==e)
comparison
comparison
(a==b & b==c & c==d & d==e)
help inline
f=inline('x^2+y','x','y')
help Func
f(2)
f(2,3)
f=inline('x^2+x')
f(2)
a = 5;
mag(a)
abs(a)
help abs
size(a)
length(a)
a==b==c
comparison
a==b==c
a==b
b==c
a==b&b==c
help same
help compare
a=[5 6 7 8 9];
b=ismember('5',a)
help lookup
b=lookup('5',a)
b=lookup(a,5)
b=lookup(a,6)
a=[5 6 7 8 9];
b=lookup(a,9)
count(5)
help count
help val
idx(5)
help ismember
clc
help ismember
tf = ismember(a,5)
tf = ismember(a,2)
tf = ismember(a,9)
help logical
help Count
Count(a,'==5')
mode(a)
a
mode(a)
a=[6 7 8 9];

mode(a)
a=[6 7 8 7];
mode(a)
run_count(a)
run_count(a,5)
a=[6 7 8 9];
run_count(a,5)
run_count(a)
help histc
clc
help histc
histc(a,5)
histc(a,6)
histc(a,7)
histc(a,8)
a=[6 6 6 9];
histc(a,6)
help hist
max(a)
help fscanf
# Octave 3.6.0, Fri Feb 24 15:44:19 2012 South Africa Standard Time <unknown@Use
r-PC>
1:10
for k=1:10;
a = a(k)
end
help sum
clc
a=0;
for k=1:10;
a=a+k;
end
a
a=0;
for k=1:10;
a=a+k;
k
end
comparison
k=0
4.0*(-1)^k/(2*k+1)
k=1
4.0*(-1)^k/(2*k+1)
k=2
4.0*(-1)^k/(2*k+1)
help abs
abs(-6)
abs(-60)
new2
total
new2
new2
new2
new2
format long
total
comparison
comparison
comparison
comparison

a = reshape (1:8, 2, 2, 2)
comparison
comparison
comparison
comparison
comparison
comparison
comparison
comparison
comparison
new3
new3
e
new3
comparison
comparison
comparison
new3
new3
new3
new3
new3
helpmod
help mod
# Octave 3.6.0, Fri Mar 02 15:57:58 2012 South Africa Standard Time <unknown@Use
r-PC>
1/3
format long e
1/3
format long e8
format long e+8
format e+8
round2(pi,1e-4) round2(pi,1e-4)
round2(1/3,1e-4)
help round2
help round
round(1/3,1e-4)
sprintf('%10.8f',1/3)
sprintf('%10.2f',1/3)
sprintf('%10.3f',1/3)
sprintf('%10.4f',1/3)
sprintf('%10.4f',pi)
sprintf('%10.4g',pi)
exit
# Octave 3.6.0, Mon Mar 05 16:03:49 2012 South Africa Standard Time <unknown@Use
r-PC>
a(1,1)=1;
a(2,2)=3;
a
A = rand(10,8)
1: % Create a random matrix A
2: A = rand(10,8);
3: % Create a random vector a
4: a = rand(8,1);
5: % Get the size of the matrix A
6: [Rows,Columns] = size(A);
7: % For loop over the number of rows
8: for i=1:Rows
9: % Initialize the i-th entry of the c-vector with zero
10: c(i,1) = 0.0;

11: % For loop over the number of columns


12: for j=1:Columns
13: % Add the appropriate term to the c-vector
14: c(i,1) = c(i,1) + A(i,j)*a(j);
15: end
16: end
17: % Displays output
18: disp('The product of matrix A with vector a is')
k=10;
prod(1:k)
a = [5 4 3 2 1]
n = length(a)
for i=1:n-1
for j=i+1:n
if a(i)>a(j)
a_copy = a(i)
a(i) = a(j)
a(j) = a_copy
end
end
a
end
i=2
i+
b=i+
i=i+
i=+i
+i
+i
i+
A = [ 2 3 4 1;1 1 2 1;2 4 5 2;1 2 3 4 ]
a=[10;5;13;10]
b=inv(A)*a
a = 'Hello how are you'
b=1*a
b = char(b)
quote = ...
"First things first, but not necessarily in that order"
quote(quote==" ")="_"
quote(quote=="_")=""
quote(quote=="_")=""
quote(quote=="_")=" "
findstr ("ababab", "a")
# Octave 3.6.0, Fri Mar 23 16:46:35 2012 South Africa Standard Time <unknown@Use
r-PC>
edit
(round(rand(length(a-1)*rand()+1)))5
(round(rand(length(5-1)*rand()+1)))5
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))

(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
(round((length(5-1)*rand()+1)))
# Octave 3.6.0, Mon Mar 26 15:09:29 2012 South Africa Standard Time <unknown@Use
r-PC>
(round(rand((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
(round(((5-1)*rand()+1)))
cd c:\octave\octave3.4.3_gcc4.5.2\
new_2
new_2
apple
apple
new_2
apple
aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)

aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)
aa=round((a-1)*rand()+1)
new_2
apple
new_2
apple
a(i)
new_2
apple
new_2
apple
new_2
apple
new_2
apple
new_2
new_2
apple
new_2
new_2
apple
new_2
apple
new_2
apple
new_2
apple
# Octave 3.6.0, Mon Mar 26 15:39:53 2012 South Africa Standard Time <unknown@Use
r-PC>
v = [1 2 0 443 41 52 16];
sort(v,'ascend')
v = [1,2,0,443,41,52,16];
sort(v,'ascend')
kk=v(1:4)
kk=sort(v,'ascend',(1:4))
kk=sort(v,'ascend');
kk=kk(1:4)
# Octave 3.6.0, Wed May 09 15:32:17 2012 South Africa Standard Time <unknown@Use
r-PC>
# Octave 3.6.0, Wed May 16 10:25:24 2012 South Africa Standard Time <unknown@Use
r-PC>

S-ar putea să vă placă și