Académique Documents
Professionnel Documents
Culture Documents
Group: I3 A2
Report
Basic Operation in MATLAB
I. Objective
Understanding the characteristic of the Basic Operation in Matlab
Scalar, Array, and Matrix
Command window, Script, Workspace and Current folder
Input and Output
o The command ‘Input’
o The command ‘Displays’
o The command ‘Plot’
II. Processive
A scalar is a value in a single element. Mostly, the scalar can be referred to one-
dimension array or 1-by-1 matrix
Array is the most fundamental data type in MATLAB. It is a collection of several
value of the same type. i.e. string array, integer array…etc. Basically, array is a vector
of the same data set.
Matrix is the array with more than one dimension.
1. Command window
Command window is place that you can put your individual statement (code)
Note: between each value there is a space and there is a semicolon (‘;’) to
2. A script
A script is a file with a .m extension (file type i.e. square .m) that contains multiple
sequential lines of MATLAB commands and function calls. You can run a script by typing
its name at the command line.
1
o Create a script that allow you to input two difference types of variable (array,
scalar or matrix) and display the value of those variable in the commend
window.
clear all;
clc;
display(First_data);
display(Second_data);
o Create a script that allow you to show any graph of sinusoidal wave form
y=A*sin((2*pi*f*Time)+phi).
clear all;
clc;
Time=T_start:T_sampling:T_stop;
y=A*sin((2*pi*f*Time)+phi);
plot(Time,y);
title('SinGraph');
xlabel('Time [s]');
ylabel('Amplitude');
xlim([T_start T_stop]);
grid minor;
2
III. Result
1. Command Window
3
2. Create a script
4
Figure 5: The graph of y=A*sin((2*pi*f*time)+phi)
IV. Discussion
1. For figure 1: A array in command window 8 element. To create this array, you go
command window and typing A= [1 2 5 8 9 0 4 10] and then your press’ ENTER’.
2. For figure 2: Create a 2-by-2 matrix. To create this matrix, you go command window and
typing A= [1 2 3 5;2 6 8 0] and then you press ‘ENTER’.
3. For figure 3: Create a script that allow you to input two difference types of variable
(array, scalar or matrix) and display the value of those variable in the commend window.
4. For figure 4: Create a script that allow you to show any graph of sinusoidal wave form
y=A*sin((2*pi*f*Time)+phi) and display the value of those variable in the commend
window.
5
f=input('Set frequency [Hz] =');% Input frequency
grid minor;% open the sall grid and then press ’RUN’ .
V. Conclusion
1. Command window is place that you can put your individual statement (code)
2. To create this script, you must create a script as show in the previous part by using
file name as “SinGraph”. Note: you can use any file name as you want. Then, you
write the code to the script as below. After running the script, you can set the value
of the input at the command window. Note: if you satisfy with your first data, you
must click “ENTER” in order to set the second value.