0% found this document useful (0 votes)
15 views23 pages

Experiment-6 Execution of MATLAB Programs

Uploaded by

prakalya.bt22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views23 pages

Experiment-6 Execution of MATLAB Programs

Uploaded by

prakalya.bt22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

EXPERIMENT-6

Execution of MATLAB programs

1)Plot the sine function over three different ranges using different line styles, colors, and
markers

Input:

t = 0:pi/20:2*pi;
plot(t,sin(t),'-.r*')
hold on
plot(t,sin(t-pi/2),'--mo')
plot(t,sin(t-pi),':bs')
hold off

output:

2) Create a plot illustrating how to set line properties.

Input:
t = 0:pi/20:2*pi;
figure
plot(t,sin(2*t),'-mo',...
'LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor',[.49 1 .63],...
'MarkerSize',10)

Output:

3) Create a graph for sine function

Sine curve: This script creates data points on a sine curve and plots them

Input:

Create data

dx = 0.1;
x = 0:dx:4*pi;
y = sin(x)

Plot Data

plot(x,y)
ylabel('sine')
xlabel ('radians')
x = [0 : 0.01: 10];
y = sin(x);
g = cos(x);
plot(x, y, x, g, '.-'),
legend('Sin(x)', 'Cos(x)')

output:
4) Draw the graph of two polynomials

f(x) = 3x4 + 2x3+ 7x2 + 2x + 9 and

g(x) = 5x3 + 9x + 2

Create a script file and type the following code –

Input:

x = -10 : 0.01: 10;


y = 3*x.^4 + 2*x.^3 + 7*x.^2 + 2*x + 9;
g = 5*x.^3 + 9*x + 2;
plot(x, y, 'r', x, g, 'g')

output:

5) Find the addition,subtraction and multiplication :

Input:

A=[1 2 3; 4 5 6; 7 8 9]

B=[1 2 -9; 2 -1 2; 3 -4 3]

C= A+B
D=A-B

E=A*B

Output:

6) To find the transpose of the matrix B

Input:

B=[1 2 -9; 2 -1 2; 3 -4 3]
C=B'

Output:

7) To find the inverse of matrix A :

Input:
A = [1 2 1; 2 3 2; 3 2 5]
B=inv(A)

Output:

8) A group of people took a trip by bus at Rs.3 per child and Rs.3.2 per adult for a total of
Rs.118.4. On their return journey, they took a train back at Rs.3.5 per child and Rs.3.6 per
adult for a total of Rs.135.20. Calculate or find how many adults and children were there
in the group.

Input:

A=[3 3.5; 3.2 3.6]


B=[118.4 135.2]
C=inv(A)
X=B*C

Output:

9) Find the roots of the equation :

Input:

V=[6,-41,97,-97,41,-6]
S=roots(V);
disp("first root is"),disp(S(1))
disp("second root is"),disp(S(2))
disp("third root is"),disp(S(3))
disp("fourth root is"),disp(S(4))
disp("fifth root is"),disp(S(5))

Output:

10) Fnd the values of x,y,z

Input:

A=[1,1,1;1,2,3;1,4,9]
B=[3;4;6]
C=A\B

Output:

11) For polynomial function:


1.Compute f(2)

Input:

p=[8 -7 12 -5 8 13 -12 9]

polyval(p,2)

Output:

2.Roots for f(x)

Input:

p=[8 -7 12 -5 8 13 -12 9]
roots(p)

Output:

3.Plot for 0<x<20

Input:

p=[8 -7 12 -5 8 13 -12 9]
X=0:1:20
y=polyval(p,X)
plot(X,y)
Output:

1)

Input:
m1 = sbiomodel('simpleModel')
r1 = addreaction(m1,'A -> B')
m1.species

m1.species(1).InitialAmount = 10
kineticLaw = addkineticlaw(r1,'MassAction')
p1 = addparameter(kineticLaw,'k',0.5)
kineticLaw.ParameterVariableNames = 'k'
sd = sbiosimulate(m1)
sbioplot(sd)

Output:

2) Simulate the Glucose-Insulin Response

(a)
sbioloadproject('insulindemo', 'm1')
>> warnSettings =
warning('off','SimBiology:DimAnalysisNotDone_MatlabFcn_Dimensionless');

>> mealDose = sbioselect(m1, 'Name', 'Single Meal'); get(mealDose)

ans = struct with fields:

Amount: 78

Interval: 0

Rate: 0

RepeatCount: 0

StartTime: 0

Active: 0

AmountUnits: 'gram'

DurationParameterName: ''

EventMode: 'stop'

LagParameterName: ''

RateUnits: ''

TargetName: 'Dose'

TimeUnits: 'hour'

Annotation: ''

Name: 'Single Meal'

Parent: [1×1 SimBiology.Model]

Notes: ''

Tag: ''

Type: 'repeatdose'

UserData: []
>> configset = getconfigset(m1,'active'); configset.StopTime = 7;

>> configset.TimeUnits

ans = 'hour'

>> normalMealSim = sbiosimulate(m1, configset, [], mealDose);

>> diabeticVar = sbioselect(m1,'Name', 'Type 2 diabetic')

diabeticVar =

SimBiology Variant - Type 2 diabetic (inactive)

ContentIndex: Type: Name: Property: Value:

1 parameter Plasma Volume ... Value 1.49

2 parameter k1 Value 0.042

3 parameter k2 Value 0.071

4 parameter Plasma Volume ... Value 0.04

5 parameter m1 Value 0.379

6 parameter m2 Value 0.673

7 parameter m4 Value 0.269

8 parameter m5 Value 0.0526

9 parameter m6 Value 0.8118

10 parameter Hepatic Extrac... Value 0.6

11 parameter kmax Value 0.0465

12 parameter kmin Value 0.0076

13 parameter kabs Value 0.023

14 parameter kgri Value 0.0465

15 parameter f Value 0.9

16 parameter a Value 6e-05

17 parameter b Value 0.68


18 parameter c Value 0.00023

19 parameter d Value 0.09

20 parameter Stomach Glu Af... Value 125

21 parameter kp1 Value 3.09

22 parameter kp2 Value 0.0007

23 parameter kp3 Value 0.005

24 parameter kp4 Value 0.0786

25 parameter ki Value 0.0066

26 parameter [Ins Ind Glu U... Value 1

27 parameter Vm0 Value 4.65

28 parameter Vmx Value 0.034

29 parameter Km Value 466.21

30 parameter p2U Value 0.084

31 parameter K Value 0.99

32 parameter alpha Value 0.013

33 parameter beta Value 0.05

34 parameter gamma Value 0.5

35 parameter ke1 Value 0.0007

36 parameter ke2 Value 269

37 parameter Basal Plasma G... Value 164.18

38 parameter Basal Plasma I... Value 54.81

>> diabeticMealSim = sbiosimulate(m1, configset, diabeticVar,mealDose);

>> outputNames = {'Plasma Glu Conc', 'Plasma Ins Conc', 'Glu Prod', 'Glu Appear Rate', 'Glu
Util', 'Ins Secr'};

>> figure;
>> for i = 1:numel(outputNames)

subplot(2, 3, i);

[tNormal, yNormal ] = normalMealSim.selectbyname(outputNames{i});

[tDiabetic, yDiabetic] = diabeticMealSim.selectbyname(outputNames{i});

plot( tNormal , yNormal , '-' , tDiabetic , yDiabetic , '--' );

% Annotate figures

outputParam = sbioselect(m1, 'Name', outputNames{i});

title(outputNames{i});

xlabel('time (hour)');

if strcmp(outputParam.Type, 'parameter')

ylabel(outputParam.ValueUnits);

else

ylabel(outputParam.InitialAmountUnits);

end

xlim([0 7]);

% Add legend

if i == 3

legend({'Normal', 'Diabetic'}, 'Location', 'Best');

end

end

Input:
Output:
(b)
configset.StopTime = 24;

dayDose=sbioselect(m1,'Name','Daily Life');

>> normalDaySim = sbiosimulate(m1, configset, [], dayDose);

impairVars{1} = sbioselect(m1, 'Name', 'Low insulin sensitivity' );

impairVars{2} = [impairVars{1}, sbioselect(m1, 'Name', 'High beta cell responsivity')];

impairVars{3} = sbioselect(m1,'Name', 'Low beta cell responsivity');

impairVars{4} = [impairVars{3}, sbioselect(m1, 'Name', 'High insulin sensitivity' )];

>> for i = 1:4

impairSims(i) = sbiosimulate(m1, configset, impairVars{i}, dayDose);

end

>> figure;

>> outputNames = {'Plasma Glu Conc', 'Plasma Ins Conc'};

>> legendLabels = {{'Normal'}, {'-Ins =\beta', '-Ins +\beta'}, {'=Ins -\beta', '+Ins -\beta'}};

>> yLimits = [80 240; 0 500];

>> for i = 1:numel(outputNames)

[tNormal, yNormal] = selectbyname(normalDaySim , outputNames{i} );

[tImpair, yImpair] = selectbyname(impairSims , outputNames{i} );


% Plot Normal

subplot(2, 3, 3*i-2 );

plot(tNormal, yNormal, 'b-');

xlim([0 24]);

ylim(yLimits(i,:));

xlabel('time (hour)');

legend(legendLabels{1}, 'Location', 'NorthWest');

% Plot Low Insulin

subplot(2, 3, 3*i-1 );

plot(tImpair{1}, yImpair{1}, 'g--', tImpair{2}, yImpair{2}, 'r:');

xlim([0 24]);

ylim(yLimits(i,:));

xlabel('time (hour)');

legend(legendLabels{2}, 'Location', 'NorthWest');

title(outputNames{i});

% Plot Low Beta

subplot(2, 3, 3*i );

plot(tImpair{3}, yImpair{3}, 'c-', tImpair{4}, yImpair{4}, 'm-');

xlim([0 24]);

ylim(yLimits(i,:));

xlabel('time (hour)');

legend(legendLabels{3}, 'Location', 'NorthWest');

end

>>

Input:
Output:
3) To Explore the sequence viewer app

>>seqviewer

(a) To retrieve a sequence from the NCBI database


select File > Download Sequence from > NCBI.

In the Enter Sequence box, type an accession number for an NCBI


database entry, for example, NM_000520. Click the Nucleotide option
button, and then click OK
(b) To show the search results for ORFs in the six reading frames.

(c) To show the protein coding part of a nucleotide sequence


Click Annotated CDS to show the protein coding part of a nucleotide
sequence
(d) Searching for Words
Sequence > Find Word

(e) Exploring Open Reading Frames


(f) The ORF is highlighted to indicate the part of the sequence that is
selected.

(g) The NM_000520_ORF_2 variable is added to the MATLABWorkspace

You might also like