Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
xlsx',w,'msc03_assign','B3')
[num txt raw]=xlsread('D:\manuals group_1.xlsx','msc03_assign','B3:D6')
num =
1
4
6
2
5
7
3
6
8
txt =
'kojo'
'ama'
'kofi'
'ama'
[ 2]
[ 5]
[ 7]
'kofi'
[ 3]
[ 6]
[ 8]
raw =
'kojo'
[ 1]
[ 4]
[ 6]
diary D:\group1.doc
help save
<strong>save</strong> Save workspace variables to file.
<strong>save</strong>(FILENAME) stores all variables from the current worksp
ace in a
MATLAB formatted binary file (MAT-file) called FILENAME.
<strong>save</strong>(FILENAME,VARIABLES) stores only the specified variable
s.
<strong>save</strong>(FILENAME,'-struct',STRUCTNAME,FIELDNAMES) stores the f
ields of the
specified scalar structure as individual variables in the file. If you
include the optional FIELDNAMES, the <strong>save</strong> function stores o
nly the
specified fields of the structure. You cannot specify VARIABLES and
the '-struct' keyword in the same call to <strong>save</strong>.
<strong>save</strong>(FILENAME, ..., '-append') adds new variables to an exi
sting file.
You can specify '-append' with additional inputs such as VARIABLES,
'-struct', FORMAT, or VERSION.
<strong>save</strong>(FILENAME, ..., FORMAT) saves in the specified format:
'-mat' or
'-ascii'.
You can specify FORMAT with additional inputs such as VARIABLES,
'-struct', '-append', or VERSION.
<strong>save</strong>(FILENAME, ..., VERSION) saves to MAT-files in the spec
ified
version: '-v4', '-v6', '-v7', or '-v7.3'.
You can specify VERSION with additional inputs such as VARIABLES,
'-struct', '-append', or FORMAT.
<strong>save</strong> FILENAME ... is the command form of the syntax, for co
nvenient
saving from the command line. With command syntax, you do not need to
'-regexp', EXPRESSIONS
rong> treats
all inputs as regular expressions except
the optional FILENAME and STRUCTNAME. The
FILENAME input must appear first. For
more information on regular expressions,
type "doc regexp" at the command prompt.
'-struct', STRUCTNAME, FIELDNAMES: Save the fields of a scalar
structure as individual variables in the file. FIELDNAMES is optional;
specify to save only selected fields. FIELDNAMES use the same forms as
VARIABLES.
'-append': Add data to an existing file. For MAT-files, '-append' adds
new variables to the file or replaces the saved values of existing
variables with values in the workspace. For ASCII files, '-append'
adds data to the end of the file.
FORMAT: Specify the format of the file, regardless of any specified
extension. Use one of the following combinations:
'-mat'
'-ascii'
'-ascii', '-tabs'
'-ascii', '-double'
'-ascii', '-double', '-tabs'
For ASCII file formats, the <strong>save</strong> function has the follo
wing
limitations:
* Each variable must be a two-dimensional double or char array.
* MATLAB translates characters to their corresponding internal
ASCII codes. For example, 'abc' appears in an ASCII file as:
9.7000000e+001 9.8000000e+001 9.9000000e+001
* The output includes only the real component of complex numbers.
* If you plan to use the LOAD function to read the file, all
variables must have the same number of columns.
VERSION: Create a MAT-file that you can load into an earlier version of
COM/save">COM/save</a>
ccsdebug/save">ccsdebug/save</a>
mdevproject/save">mdevproject/save</a>
cgproject/save">cgproject/save</a>
vrworld/save">vrworld/save</a>
Size
A
B
C
ama
ans
c
d
e
k
kofi
kojo
m
n
num
p
raw
txt
w
x
y
z
Bytes Class
3x3
3x3
3x6
3x1
3x3
6x1
3x3
1x10
3x5
3x1
3x1
1x1
1x1
3x3
1x1
4x3
1x3
4x3
1x1
1x1
1x100
72
72
144
24
72
48
72
80
120
24
24
60
60
72
60
814
202
814
60
8
800
Attributes
double
double
double
double
double
double
double
double
double
double
double
sym
sym
double
sym
cell
cell
cell
sym
double
double
who
Your variables are:
A
B
C
ama
ans
c
d
e
k
kojo n
kofi m
num
p
raw
txt
w
x
y
clc
cr=[2,3,3];
mks=[50,80,90];
%try program%
%progrma to calculate cwa given cr & mks%
%----------------------------------cr=[2,3,3];
mks=[50,80,90];
%---------------------------------cwa=(cr(1)*mks(1)+cr(2)*mks(2)+cr(3)*mks(3))/(cr(1)+cr(2)+cr(3))
cwa =
76.2500
clc
%try program%
%progrma to calculate cwa given cr & mks%
%----------------------------------cr=[2,3,3];
mks=[50,80,92];
%---------------------------------cwa=(cr(1)*mks(1)+cr(2)*mks(2)+cr(3)*mks(3))/(cr(1)+cr(2)+cr(3))
cwa =
77
cr=input('Please enter 3 credit hours':);
cr=input('Please enter 3 credit hours':);
|
{Error: Unbalanced or unexpected parenthesis or bracket.
}
clc
%try program%
%progrma to calculate cwa given cr & mks%
%----------------------------------cr=[2,3,3];
mks=[50,80,92];
%---------------------------------cwa=(cr(1)*mks(1)+cr(2)*mks(2)+cr(3)*mks(3))/(cr(1)+cr(2)+cr(3))
cwa =
77
cr=input('Please enter 3 credit hours');
Please enter 3 credit hourscr=input('Please enter 3 credit hours');
{Error: The expression to the left of the equals sign is not a valid target for a
n assignment.
}
Please enter 3 credit hoursclc
{Error using <a href="matlab:helpUtils.errorDocCallback('clc')" style="font-weigh
t:bold">clc</a>
Too many output arguments.
}
Please enter 3 credit hours
clc
%try program%
%progrma to calculate cwa given cr & mks%
%----------------------------------cr=[2,3,3];
mks=[50,80,92];
%---------------------------------cwa=(cr(1)*mks(1)+cr(2)*mks(2)+cr(3)*mks(3))/(cr(1)+cr(2)+cr(3))
cwa =
77
cr=input('Please enter 3 credit hours:');
Please enter 3 credit hours:
clc
%try program%
%progrma to calculate cwa given cr & mks%
%----------------------------------cr=[2,3,3];
mks=[50,80,92];
%---------------------------------cwa=(cr(1)*mks(1)+cr(2)*mks(2)+cr(3)*mks(3))/(cr(1)+cr(2)+cr(3))
cwa =
77
cr=input('Please enter 3 credit hours
:');
Please enter 3 credit hours
:[2 3 3]
mks=input('Please enter corresponding marks
:');
Please enter corresponding marks
:[50 80 92]
clc
%try program%
%progrma to calculate cwa given cr & mks%
%----------------------------------cr=input('Please enter 3 credit hours
:');
Please enter 3 credit hours
:[2 3 3]
mks=input('Please enter corresponding marks
:');
Please enter corresponding marks
:[50 80 92]
%---------------------------------cwa=(cr(1)*mks(1)+cr(2)*mks(2)+cr(3)*mks(3))/(cr(1)+cr(2)+cr(3))
cwa =
77
%try program%
%progrma to calculate cwa given cr & mks%
%----------------------------------cr=input('Please enter 3 credit hours
:');
Please enter 3 credit hours
:[3 3 2]
mks=input('Please enter corresponding marks
:');
Please enter corresponding marks
:[90 90 90]
%---------------------------------cwa=(cr(1)*mks(1)+cr(2)*mks(2)+cr(3)*mks(3))/(cr(1)+cr(2)+cr(3));
%------------------------------------disp('The Cummulative Weighted average(cwa)is
:')
The Cummulative Weighted average(cwa)is
:
disp(cwa)
90
%Example 1 on fprintf:
x=500;
%\n is used to create anew line space
fprintf('The value of x is %f. \n', x)
The value of x is 500.000000.
%The value of x will be on a line below
fprintf('The value of x is \n %f. ', x)
The value of x is
500.000000. %Example 2 on fprintf:
smiles = 77;
fprintf('John smiles %d times a day. ', smiles)
John smiles 77 times a day.
%Example 2 on fprintf:
me=input('Please Enter your name: ','s')
Please Enter your name: Michael
me =
Michael
smiles = input('How mant times do ou smilea day? ')
How mant times do ou smilea day? 3
smiles =
3
fprintf('I, %s smile %d times a day. ', me,smiles)
I, Michael smile 3 times a day.
%Example 2 on fprintf:
me=input('Please Enter your name: ','s')
Please Enter your name: Michael
me =
Michael
smiles = input('How mant times do you smile a day? ')
How mant times do you smile a day? 1900
smiles =
1900
fprintf('I, %s smile %d times a day. ', me,smiles)
I, Michael smile 1900 times a day.
%Example 2 on fprintf:
me=input('Please Enter your name: ','s')
Please Enter your name: 1300
me =
1300
smiles = input('How many times do you smile a day? ')
How many times do you smile a day?
smiles =
[]
fprintf('I, %s smiles %d times a day. ', me,smiles)
I, 1300 smiles times a day.
%Example 2 on fprintf:
me=input('Please Enter your name: ','s')
Please Enter your name: Michael
me =
Michael
smiles = input('How many times do you smile a day? ')
How many times do you smile a day? 600
smiles =
600
fprintf('I, %s smiles %d times a day. ', me,smiles)
I, Michael smiles 600 times a day.
%Example 2 on fprintf:
me=input('Please Enter your name: ','s')
Please Enter your name: Michael
me =
Michael
smiles = input('How many times do you smile a day? ')
How many times do you smile a day? 9876
smiles =
9876
fprintf('I, %s smiles %d times a day. ', me,smiles)
I, Michael smiles 9876 times a day.
%Example 2 on fprintf:
me=input('Please Enter your name: ','s')
Please Enter your name: Nana
me =
Nana
smiles = input('How many times do you smile a day? ')
How many times do you smile a day? 87
smiles =
87
fprintf('I, %s smiles %d times a day. ', me,smiles)
I, Nana smiles 87 times a day.
%Example 3 on fprintf:
month = input('Please enter your month of birth (i.e. Jan, etc: ', 's');
Please enter your month of birth (i.e. Jan, etc: October
day = input('Please enter in number your day of birth: ');
Please enter in number your day of birth: 14
fprintf('Your birthday is %s %d !! so many years ago', month, day)
Your birthday is October 14 !! so many years ago
%Comprehensive programme to compute roots of quadratic equation
% START OF CODE
% Quadratic equation roots based
% on the theoretical formula for the roots.
%
%
a .* x.^2 + b .* x + c = 0
%
% Step 1: Start
clear;clc
format compact
disp(' ')
')
')
else if cwa>=50
disp('pass')
else
disp('fail')
end
cwa=input('Please enter your cwa:....
if cwa>=80;
disp('first class')
elseif cwa>=70;
disp('second class Upper')
elseif cwa>=60;
disp('second class lower')
elseif cwa>=50
disp('pass')
else
disp('fail')
end
')
')
tting
'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics p
age of the
configuration parameters dialog]
[Warning: Using a default value of 0.2 for maximum step size. The simulation ste
p size
will be equal to or less than this value. You can disable this diagnostic by se
tting
'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics p
age of the
configuration parameters dialog]
[Warning: Using a default value of 0.2 for maximum step size. The simulation ste
p size
will be equal to or less than this value. You can disable this diagnostic by se
tting
'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics p
age of the
configuration parameters dialog]
clc
B=[3,0,1;7,2,0;0,5,4]
B =
3
0
1
7
2
0
0
5
4
A=[3 0 1
7 2 0
0 5 4]
A =
3
0
1
7
2
0
0
5
4
help det
<strong>det</strong>
Determinant.
<strong>det</strong>(X) is the determinant of the square matrix X.
Use COND instead of <strong>det</strong> to test for matrix singularity.
See also <a href="matlab:help cond">cond</a>.
Overloaded methods:
<a href="matlab:help
<a href="matlab:help
<a href="matlab:help
<a href="matlab:help
sym/det">sym/det</a>
gf/det">gf/det</a>
gpuArray/det">gpuArray/det</a>
laurmat/det">laurmat/det</a>
3
4
1
95
det(B)
ans =
59
det(b)
ans =
225
fliplr(B)
ans =
1
0
4
flipud(B)
ans =
0
7
3
rot90(B)
ans =
1
0
3
rref(A)
ans =
1
0
0
diag(A)
ans =
2
5
1
trace(A)
ans =
8
0
2
5
3
7
0
5
2
0
4
0
1
0
2
7
4
5
0
0
1
0
0
0
1
6
0
0
10
0
30
A(3,[1 3])
ans =
-7
1
B([1:3],3)
ans =
1
0
4
A(:,1)
ans =
2
0
-7
B(3,2)
ans =
5
A(4)
ans =
-1
3
0
4
A.*B
ans =
x=-2:2:15
x =
-2
0
2
4
6
8
10
12
14
y=1:10
y =
1
2
3
4
5
6
7
8
9
10
x(3:end-2)
ans =
2
4
6
8
10
y(1:end/2)
ans =
1
2
3
4
5
linspace(0,2,6)
ans =
0
0.4000
0.8000
1.2000
1.6000
2.0000
x=1:3;
y=4:6;
g=3.*x.^2+2.*y.^2-6.*x.*y
g =
11
2
-9
disp
{Error using <a href="matlab:helpUtils.errorDocCallback('disp')" style="font-weig
ht:bold">disp</a>
Not enough input arguments.}
disp('x-5*x^2+1')
x-5*x^2+1
sqrt(y(1))
ans =
2
f=inline('x^2+y^2','x','y')
f =
Inline function:
f(x,y) = x^2+y^2
x(2)^2-x(3)*y(3)+y(2)^2
ans =
11
me=input('Please Enter your name: ','s')
Please Enter your name: me =
''
me=input('Please Enter your name: ','s')
Please Enter your name: mike
me =
mike
help %s
HELP topics:
<a href="matlab:help matlabhdlcoder\matlabhdlcoder">matlabhdlcoder\matlabhdlcode
r</a> - (No table of contents file)
<a href="matlab:help matlabxl\matlabxl">matlabxl\matlabxl</a>
- MAT
LAB Builder EX
<a href="matlab:help matlab\demos">matlab\demos</a>
- Examples
.
<a href="matlab:help matlab\graph2d">matlab\graph2d</a>
- Two di
mensional graphs.
<a href="matlab:help matlab\graph3d">matlab\graph3d</a>
- Three
dimensional graphs.
<a href="matlab:help matlab\graphics">matlab\graphics</a>
- Handl
e Graphics.
<a href="matlab:help matlab\plottools">matlab\plottools</a>
- Grap
hical plot editing tools
- Annotat
- Spec
- Graphi
- General
- Optim
- Comm
- Data a
- (N
- Data
- Elementa
- Elementa
- Functio
- Genera
- Graphica
- Help
- File inp
- Programmi
- Matrix
- Operators
- Interp
- Random
- Sparse
- Specia
- Charact
- Time a
- Versio
- Windows
- Using .NET
- S
- Differen
of contents file)
<a href="matlab:help trading\trading">trading\trading</a>
- Tradi
ng Toolbox
<a href="matlab:help vision\vision">vision\vision</a>
- Compute
r Vision System Toolbox
<a href="matlab:help vision\visionutilities">vision\visionutilities</a>
- (No table of contents file)
<a href="matlab:help visionutilities\visioninit">visionutilities\visioninit</a>
- (No table of contents file)
<a href="matlab:help visionutilities\visionmex">visionutilities\visionmex</a>
- (No table of contents file)
<a href="matlab:help vnt\vnt">vnt\vnt</a>
- Vehicle Netwo
rk Toolbox
<a href="matlab:help vnt\vntguis">vnt\vntguis</a>
- (No table
of contents file)
<a href="matlab:help vnt\vntdemos">vnt\vntdemos</a>
- (No tabl
e of contents file)
<a href="matlab:help vntblks\vntblks">vntblks\vntblks</a>
- (No t
able of contents file)
<a href="matlab:help vntblks\vntmasks">vntblks\vntmasks</a>
- (No
table of contents file)
<a href="matlab:help wavelet\wavelet">wavelet\wavelet</a>
- Wavel
et Toolbox
<a href="matlab:help wavelet\wmultisig1d">wavelet\wmultisig1d</a>
- (
No table of contents file)
<a href="matlab:help wavelet\wavedemo">wavelet\wavedemo</a>
- (No
table of contents file)
<a href="matlab:help wavelet\compression">wavelet\compression</a>
- (
No table of contents file)
<a href="matlab:help xpc\xpc">xpc\xpc</a>
- xPC Target
<a href="matlab:help xpcblocks\thirdpartydrivers">xpcblocks\thirdpartydrivers</a
>
- (No table of contents file)
<a href="matlab:help build\xpcblocks">build\xpcblocks</a>
- xPC T
arget -- Blocks
<a href="matlab:help build\xpcobsolete">build\xpcobsolete</a>
- (No
table of contents file)
<a href="matlab:help xpc\xpcdemos">xpc\xpcdemos</a>
- xPC Targ
et -- examples and sample script files.
lookfor %s
{Error using <a href="matlab:helpUtils.errorDocCallback('lookfor')" style="font-w
eight:bold">lookfor</a>
Not enough input arguments.}
%s
%8.3f
weight = 23476.54;
fprintf( The weight is %8.2f pounds \n , weight)
fprintf( The weight is %8.2f pounds \n , weight)
|
{Error: The input character is not valid in MATLAB statements or expressions.
}
weight = 23476.54;
fprintf('The weight is %8.2f pounds \n' , weight)
The weight is 23476.54 pounds
fprintf( The weight is %50.2f pounds \n , weight)
fprintf( The weight is %50.2f pounds \n , weight)
|
{Error: The input character is not valid in MATLAB statements or expressions.
}
fprintf('The weight is %50.2f pounds \n' , weight)
The weight is
help weight
23476.54 pounds
axes
help axes
<strong>axes</strong> Create axes in arbitrary positions.
<strong>axes</strong>('position', RECT) opens up an axis at the specified lo
cation
and returns a handle to it.
RECT = [left, bottom, width, height] specifies the location and
size of the side of the axis box, relative to the lower-left
corner of the Figure window, in normalized units where (0,0)
is the lower-left corner and (1.0,1.0) is the upper-right.
<strong>axes</strong>, by itself, creates the default full-window axis and r
eturns
a handle to it.
<strong>axes</strong>(H) makes the axis with handle H current.
Execute GET(H) to see a list of axes object properties and
their current values. Execute SET(H) to see a list of axes
object properties and legal property values.
See also <a href="matlab:help subplot">subplot</a>, <a href="matlab:help axi
s">axis</a>, <a href="matlab:help figure">figure</a>, <a href="matlab:help gca">
gca</a>, <a href="matlab:help cla">cla</a>.
Reference page in Help browser
<a href="matlab:doc axes">doc axes</a>
doc axes
help function
<strong>function</strong> Add new function.
New functions may be added to MATLAB's vocabulary if they
are expressed in terms of other existing functions. The
commands and functions that comprise the new function must
be put in a file whose name defines the name of the new
function, with a filename extension of '.m'. At the top of
the file must be a line that contains the syntax definition
for the new function. For example, the existence of a file
on disk called STAT.M with:
function [mean,stdev] = stat(x)
%STAT Interesting statistics.
n = length(x);
mean = sum(x) / n;
stdev = sqrt(sum((x - mean).^2)/n);
defines a new function called STAT that calculates the
mean and standard deviation of a vector. The variables
within the body of the function are all local variables.
See SCRIPT for procedures that work globally on the workspace.
A subfunction that is visible to the other functions in the
same file is created by defining a new function with the <strong>function</s
trong>
keyword after the body of the preceding function or subfunction.
For example, avg is a subfunction within the file STAT.M:
function [mean,stdev] = stat(x)
%STAT Interesting statistics.
n = length(x);
mean = avg(x,n);
stdev = sqrt(sum((x-avg(x,n)).^2)/n);
%------------------------function mean = avg(x,n)
%AVG subfunct