Experiment-6 Execution of MATLAB Programs
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:
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:
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
g(x) = 5x3 + 9x + 2
Input:
output:
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:
Input:
B=[1 2 -9; 2 -1 2; 3 -4 3]
C=B'
Output:
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:
Output:
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:
Input:
A=[1,1,1;1,2,3;1,4,9]
B=[3;4;6]
C=A\B
Output:
Input:
p=[8 -7 12 -5 8 13 -12 9]
polyval(p,2)
Output:
Input:
p=[8 -7 12 -5 8 13 -12 9]
roots(p)
Output:
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:
(a)
sbioloadproject('insulindemo', 'm1')
>> warnSettings =
warning('off','SimBiology:DimAnalysisNotDone_MatlabFcn_Dimensionless');
Amount: 78
Interval: 0
Rate: 0
RepeatCount: 0
StartTime: 0
Active: 0
AmountUnits: 'gram'
DurationParameterName: ''
EventMode: 'stop'
LagParameterName: ''
RateUnits: ''
TargetName: 'Dose'
TimeUnits: 'hour'
Annotation: ''
Notes: ''
Tag: ''
Type: 'repeatdose'
UserData: []
>> configset = getconfigset(m1,'active'); configset.StopTime = 7;
>> configset.TimeUnits
ans = 'hour'
diabeticVar =
>> 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);
% Annotate figures
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
end
end
Input:
Output:
(b)
configset.StopTime = 24;
dayDose=sbioselect(m1,'Name','Daily Life');
end
>> figure;
>> legendLabels = {{'Normal'}, {'-Ins =\beta', '-Ins +\beta'}, {'=Ins -\beta', '+Ins -\beta'}};
subplot(2, 3, 3*i-2 );
xlim([0 24]);
ylim(yLimits(i,:));
xlabel('time (hour)');
subplot(2, 3, 3*i-1 );
xlim([0 24]);
ylim(yLimits(i,:));
xlabel('time (hour)');
title(outputNames{i});
subplot(2, 3, 3*i );
xlim([0 24]);
ylim(yLimits(i,:));
xlabel('time (hour)');
end
>>
Input:
Output:
3) To Explore the sequence viewer app
>>seqviewer