Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
2019/2020
Name: __________________________________ Student Reg. No. :
_______________ Class: _____
Task-02
Input-Output Control
Objectives:
1. to explain the function of disp()
2. to explain the function of input()
3. to explain the function of fprintf()
Instructions:
1. Open your Matlab Program. Let p = last two digits of your student
registration number (e.g. p = 12) and let q = 2p. Write your p and q values in
the below box
p=
q=
a. P = 2p + p2
b. Q = x - P / 50q
c. R = 1.8Q / pi
d. S = absolut value of R
e. T = sin (pi / 0.1S)
Copy this below script and paste in the editor window of M-file (script) to find
the answers.
Task02-1
Matlab Programming – Mechatronics Engineering – SPUP –
2019/2020
Name: __________________________________ Student Reg. No. :
_______________ Class: _____
%declare variabels
p = ………; %use your own p value
q = ………; %use your own q value
%process of calculations
P = p * 2 + p ^ 2;
Q = p - P / (50*q);
R = Q * 1.8 / pi;
S = abs (R);
T = sin (pi/(0.1*S));
Write your p and q values in the script. Save your script and run it. Print
screen the result and paste it in the below box.
2. Copy this below script and paste in the editor window of M-file (script) to find
the answers.
Task02-2
Matlab Programming – Mechatronics Engineering – SPUP –
2019/2020
Name: __________________________________ Student Reg. No. :
_______________ Class: _____
%input variabels
p = input('Input your own p = ');
q = input('Input your own q = ');
%process of calculations
P = p * 2 + p ^ 2;
Q = p - P / (50*q);
R = Q * 1.8 / pi;
S = abs (R);
T = sin (pi/(0.1*S));
Write statements for Q, R, S, and T. Save your script with a new name and run
it. Print screen the result and paste it in the below box.
3. Choose 5 cases below that you had choosen in the last semester (Algorithm
and Programming by using CodeBlocks).
Task02-3
Matlab Programming – Mechatronics Engineering – SPUP –
2019/2020
Name: __________________________________ Student Reg. No. :
_______________ Class: _____
Make a script for the 1 st case (title of case: …………….…….). Save your
script with a suitable name and run it. Copy the script and paste it in the below
box.
Make a script for the 2nd case (title of case: …………….…….). Save your
script with a suitable name and run it. Copy the script and paste it in the below
box.
Task02-4
Matlab Programming – Mechatronics Engineering – SPUP –
2019/2020
Name: __________________________________ Student Reg. No. :
_______________ Class: _____
Make a script for the 3rd case (title of case: …………….…….). Save your
script with a suitable name and run it. Copy the script and paste it in the below
box.
Make a script for the 4th case (title of case: …………….…….). Save your
script with a suitable name and run it. Copy the script and paste it in the below
box.
Task02-5
Matlab Programming – Mechatronics Engineering – SPUP –
2019/2020
Name: __________________________________ Student Reg. No. :
_______________ Class: _____
Make a script for the 5th case (title of case: …………….…….). Save your
script with a suitable name and run it. Copy the script and paste it in the below
box.
For the 5th case, copy the script of CodeBlocks in the last semester and
compare with the script of Matlab. Paste them in the below table.
Task02-6
Matlab Programming – Mechatronics Engineering – SPUP –
2019/2020
Name: __________________________________ Student Reg. No. :
_______________ Class: _____
a. disp()
b. input()
c. fprintf()
---end of T2---
Task02-7