0% found this document useful (0 votes)
34 views34 pages

Matlab Manual DR - Bhawna

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

Matlab Manual DR - Bhawna

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

RUNGTA COLLEGE OF ENGINEERING & TECHNOLOGY

Department Of Computer Science and Engineering

LAB MANUAL

Software Lab(SciLab/Matlab)
SEMESTER3rd

RUNGTACOLLEGE
Rungta Educational
Campus,Kohka-Kurud Road,
Bhilai,
Chhattisgarh, India
MANAGEDBY:SANTOSHRUNGTAGROUPOFINSTITUTIONS
Phone No. 0788-6666666

Prepared By:Dr. Bhawna Janghel Rajput


RUNGTACOLLEGEOFENGINEERING&TECHNOLOGY

DEPARTMENTOFComputerScienceandEngineering

LAB MANUAL

Software LAB
SEMESTER3rd

PREPAREDASPERTHESYLLABUSPRESCRIBEDBY

CHHATTISGARHSWAMIVIVEKANANDTECHNICALUNIVERSITY,BHILAI
ListofDOs&DON’Ts.

(Giveinstructionsasper<NameOfTheDepartment>Laboratories)DOs:

▪ Removeyourshoesoutsidethelaboratory.

▪ Comepreparedinthelabregardingtheexperimenttobeperformedinthelab.

▪ TakehelpfromtheManual/WorkBookforpreparationoftheexperiment.

▪ ForanyabnormalworkingofthemachineconsulttheFacultyIn-charge/LabAssistant.

▪ Shutdownthemachineandswitchoffthepowersupplyafterperformingtheexperiment.

▪ Maintainsilenceandproperdisciplineinthelab.

▪ EnteryourmachinenumberintheLoginregister.

DON’Ts:

▪ Donotbringanymagneticmaterialintothelab.

▪ Donoteatordrinkanythinginthelab.

▪ DonottamperwiththeinstrumentsintheLabanddonotdisturbtheirsettings.
LISTOF XPRI TS
ASPERTHESYLLABUSPRESCRIBEDBYTHEUNIVERSITY
ChhattisgarhSwamiVivekanandaTechnicalUniversity,Bhilai
Branch:ComputerScienceandEngineering Semester:III
Subject:SoftwareLaboratory(SciLAB/MATLAB)
SubjectCode:B022324(022)Tot
alLabPeriods:36 BatchSize:30
MaximumMarks:40 MinimumMarks:20

COURSEOUTCOMES
Aftersuccessfulcompletionofthiscourse,thestudentswillbeableto-

1. UnderstandthemainfeaturesoftheMATLAB/SCILABprogramdevelopmentenvironmenttoenabl
etheirusageinhigherlearning.
2. Realizethepowerofinteractivecalculation,programming,graphics,andanimationinSciL
AB/MATLABandcompleteportabilityacrossplatforms.
3. EnjoySciLAB/MATLABasascientificcomputingandvisualizationtool.
4. ExploreInteractiveComputationwithmatricesandarraysofn-dimensions.
5. Interpretandvisualizesimplemathematicalfunctionsandoperationsthereonusingplots/display.

ListofExperiments

1. Identificationofdifferentmatrixtypes.
2. Properties and Operations of arrays and matrices.
3. Writeaprogramtofindtheprobabilityoftossingacoinandrollingadiethroughalargenumber of
experimentation.
4. Compute ycoordinates of a STRAIGHT LINE y = mx + c, where slope of line m
=0.5,intercept c = - 2 and x-coordinates : x = 0 to 10 for 0.5 increments
5. Plot y=Sin x where 0 ≤x≤2.
6. Plot y = e^ - 0.4sin x where : 0 <= x <= 4
7. Find the solution of linear algebraic equations in 2 variables, 3
variables:a.x + 4y = 18; 2x + 3y = 16
b.x + 2y + 3z = 1; 3x + 3y + 4z = 1; 2x + 3y + 3z = 2
8. Determination of roots of a given polynomial & quadratic equations.
9. DeterminationofEigenValue&EigenVectorsformatrices.
10. Writeascriptfiletodrawaunitcircle.
11. Writeafunctionfactorial tocomputethefactorial n!foranyinteger n.
12. Writeafunction factorialtocompute thefactorialn! usingRECURSIONfor anyintegern
13. Writeafunctiontocomputethegeometricseries1 +
r +r2+r3+. ..............+rn for given r and n.
14. Writeafunctionfilecrossprodtocomputethecrossproductoftwovectorsuandv.
15. Design a toy project as an independent study towards problem-based learning.
RecommendedBooks

1. GettingstartedwithMATLAB:AQuickIntroductionforScientistsandEngineersbyRudraPratap,IISBangalo
re.
2. ScilabManualforProbabilityTheoryandStatisticsLabbyProfSNChandraShekhar,https://s
cilab.in/labmigrationrun/82
3. ScilabManualforNumericalTechniqueslabbyProfKanikaGupta;https://scilab.in/labmigrationrun/82
4. ScilabManualforProbabilityTheoryandRandomProcessesbyProfShitalThakkar,https:/
/scilab.in/lab_migrationrun/82.
5. ScilabManualforNumericalTechniquesbyDrJavedDhillon:https://scilab.in/labmigrationrun/82
LISTOFEXPERIMENTS
AS PER RUNGTA COLLEGE OF ENGINEERING & TECHNOLOGY

Exp. Aim Page No


No.
1 Evaluatea)eπ√163b)log10e3c)sin2π/6+cos2π/6d)3x=17 1
e)
2 Findthesumoftheintegersfrom1to100. 2
3 Generatetheseriesforagivenrandn.Also,findthesum. 3
1+r+r2+r3+ ............. rn
4 Create a 1 × 6 vector v containing the integer values from 20 to 4
25.Subsequently,createa1×6vectorwhosevaluesareequalto5timesthe
valuesinv.
5 Createavectorspanningtherangefrom0to2π,containing100equallyspacedc 5-6
omponents,sothatthefirstvalueis0,andthelastvalueis2π.
6 Createa)Matrixof0’sb)Matrixof1’sc)IdentityMatrixd)Random 7
Matrix
7 Createamatrixof10rowsand10columns.Theoddcolumnsshouldcontainaval 8
ueof2,andtheevencolumns,avalueof0.
8 Createa5x5matrix.Deletethelastrowandlastcolumnofthematrix. 9
9 Createa4x4Matrix.ShowInverseMatrix,UpperTriangleMatrix,LowerTria 10-11
ngleMatrix,DiagonalMatrix,Determinant.
10 Computey-coordinatesofastraightliney=mx+cwhereslopeofline 12
m=0.5,interceptc=-2andxcoordinates:x=0to10for0.5increments
11 Ploty=sinxwhere0≤x≤2,Ploty=e-0.4sinx0≤x≤2. 13
12 Plot4differentsignalinasinglefigurewithproperlabels. 14
13 Assumeacarcompany;Productionof6yearsfrom2010to2016isgivenas3000 15
0,25000,40000,65000,45000and20000.Writethecodetocreateabarcharttov
isualizethegiveninformation.
14 Determinationofrootsofagivenpolynomial&quadraticequations. 16
15 Findthesolutionoflinearalgebraicequationsin2variables,3variables. 17-18
a. X+47=18;2x+3y=16
b.X+2y+3z=1;3x+3y+4z=1;2x+3y+3z=2
16 DeterminationofEigenvalueandEigenvectorformatrices. 19
17 Writeascripttodrawaunitcircle. 20
18 Writeafunctionfactorialtocomputethefactorialn!Foranyintegern. 21
19 DevelopanyMatlab-basedapplication 22
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B022324(022)
Exp. Aim
No.
1 Evaluatea)eπ√163b)log10e3c)sin2π/6+ cos2π/6d)3x=17
e)

Ans: >> exp (pi*sqrt (163)


)ans=
2.6254e+17
>>
log10(exp(3))an
s=
1.3029
>> (sin(pi/6))^2 +
(cos(pi/6))^2ans=
1
>> x=log (17) /log
(3)x=
2.5789
>> 3*(sqrt(5)-1)/(sqrt(5)+1)^2 -
1ans=
-0.6459

VIVA QUESTIONS :

1. What is MATLAB?
2. Explain the Features of MATLAB.
3. Explain the Advantages and Disadvantages of MATLAB.
4. Explain all Data Types used in MATLAB.
5. What is the difference between a script and a function in MATLAB? When would you use each?

1
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B022324(022)

2 Findthesumoftheintegersfrom1 to100.
Ans: >>x=1:100;
>>

sum(x)ans

5050

>>sum(1:100)

ans=

5050

VIVA QUESTIONS:

1. Write a script that uses a for loop to calculate the sum of the first 100 integer numbers.
2. What is MATLAB syntax?
3. How to write function in MATLAB?
4. What are the three tools of MATLAB?

2
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B022324(022)

3 Generatetheseriesforagivenrandn. Alsofindthe sum.


1 +r +r2+r3 + .......... rn
Ans: >>r=input('Enteranumberforr')
Enter a number for r5r =

>>n=input('Enteranumberforn')
Enter a number for n3n=

>>sum=1;
>>x=1;
>> for
i=1:nx=x*r;sum
=sum+x;end
>>

sumsum

=156

VIVA QUESTIONS :

1. How do you find the sum of a series in Matlab?


2. What is the function series sum?
3. What is sum sum a )) in Matlab?
4. How do you sum n numbers in Matlab?

3
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B022324(022)

4 Create a 1 × 6 vector v containing the integer values from 20 to 25. Subsequently,


createa1 ×6 vectorwhosevalues areequalto 5timesthevalues inv.
Ans: >> myvector=randi([20

25],1,6)myvector=

24 25 20 25 23 20

>>

newvector=myvector.*5ne

wvector=

120125100125115100

>>

VIVA QUESTIONS :

1. How do you create a vector with repeated values in MATLAB?


2. How do you create a vector of values in MATLAB?
3. How do you make a vector of the same number?
4. What does vector mean in MATLAB?
5. What does (:) do in MATLAB?

4
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B022324(022)

5 Create a vector spanning the range from 0 to 2π, containing 100 equally
spacedcomponents,sothatthefirstvalueis0, andthe lastvalueis 2π.
Ans: >>myvector=linspace(0,2*pi,100)

myvector=

Columns1through7

0 0.0635 0.1269 0.1904 0.2539 0.3173 0.3808

Columns8through14

0.4443 0.5077 0.5712 0.6347 0.6981 0.7616 0.8251

Columns15through21

0.8885 0.9520 1.0155 1.0789 1.1424 1.2059 1.2693

Columns22through28

1.3328 1.3963 1.4597 1.5232 1.5867 1.6501 1.7136

Columns29through35

1.7771 1.8405 1.9040 1.9675 2.0309 2.0944 2.1579

Columns36through42

2.2213 2.2848 2.3483 2.4117 2.4752 2.5387 2.6021

Columns43through49

2.6656 2.7291 2.7925 2.8560 2.9195 2.9829 3.0464

Columns50through56

3.1099 3.1733 3.2368 3.3003 3.3637 3.4272 3.4907

Columns57through63

3.5541 3.6176 3.6811 3.7445 3.8080 3.8715 3.9349

Columns64through70

3.9984 4.0619 4.1253 4.1888 4.2523 4.3157 4.3792

Columns71through77

4.4427 4.5061 4.5696 4.6331 4.6965 4.7600 4.8235

Columns78through84

4.8869 4.9504 5.0139 5.0773 5.1408 5.2043 5.2677

Columns85through91

5
5.3312 5.3947 5.4581 5.5216 5.5851 5.6485 5.7120

Columns92through98

5.7755 5.8389 5.9024 5.9659 6.0293 6.0928 6.1563

Columns99through100

6.2197 6.2832

>>

VIVA QUESTIONS :

1. How do you create a vector of 100 equally spaced values in MATLAB?


2. How do you create a vector equally spaced in MATLAB?
3. What is a Matlab function to generate linearly spaced vectors?
4. Which command should we use to create vectors with logarithmically spaced entries?
5. How do you create a two row vector in MATLAB?

6
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B000324(022)
6 Createa)Matrixofzero’sb) Matrixof one’sc) Identitymatrixd)RandomMatrix
Ans: >>

x=zeros(3)x=

0 0 0
0 0 0
0 0 0

>>

x=ones(3)x=

1 1 1
1 1 1
1 1 1

>>

x=eye(3)x=

1 0 0
0 1 0
0 0 1

>>

x=rand(3)x=

0.8147 0.9134 0.2785


0.9058 0.6324 0.5469
0.1270 0.0975 0.9575

VIVA QUESTIONS :
1. How do you create a zero matrix in MATLAB?
2. How do you create a matrix of ones in MATLAB?
3. Which MATLAB command is used to create an identity matrix?

7
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B000324(022)

7 Create a matrix of 10 rows and 10 columns. The odd columns should contain values
2,andthe evencolumns, values 0.
Ans >>x=zeros(10);
>>x(:,1:2:10)=2;
>>

xx=

2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0

VIVA QUESTIONS :

1. How do I add rows and columns to a matrix in MATLAB?


2. How do you find the row sum and column sum of a matrix in MATLAB?
3. What is matrix row and column?
4. How do you select odd rows in a matrix in MATLAB?

8
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B000324(022)

8 Createa5x5matrix.Deletethelastrowandlastcolumnof thematrix.
Ans: >> x=randi([5

10],5)x=

6 7 9 10 10
9 10 6 8 6
8 7 8 5 9
5 8 9 5 6
5 6 10 6 10

>>x(:,5)=[] %Delete last

columnx=

6 7 9 10
9 10 6 8
8 7 8 5
5 8 9 5
5 6 10 6

>>x(1,:)=[]

%Deletefirstrow

x=

9 10 6 8
8 7 8 5
5 8 9 5
5 6 10 6

VIVA QUESTIONS :

1. How do I delete rows and columns from a matrix in Matlab?


2. How do you delete a matrix in Matlab?
3. How do I delete the last row of a table in Matlab?
9
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B000324(022)
4. How do you remove the last row of an array?

10
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B000324(022)

9 Create a 4x4 matrix. Show Inverse matrix, Upper triangle and Lower Triangle
Matrix,Diagonal Matrix, Determinant
Ans: >> A=[9,7,0,4; 0,8,6,9; 7,1,-6,3; 4,3,2,1]%Create a 4 x 4

MatrixA=

9 7 0 4
0 8 6 9
7 1 -6 3
4 3 2 1

>>A' %InverseMatrix

ans=

9 0 7 4
7 8 1 3
0 6 -6 2
4 9 3 1

>>triu(A) % Upper Triangle

Matrixans =

9 7 0 4
0 8 6 9
0 0 -6 3
0 0 0 1

>>tril(A) % Lower Triangle

Matrixans =

9 0 0 0
0 8 0 0
7 1 -6 0
4 3 2 1

>>diag(A) % Diagonal

Matrixans =

9
8
-6
1

>>det(A) % Matrix

determinantans =

-608.0000

11
VIVA QUESTIONS :

1. What is a row array Matlab?


2. How do you add a row to the end of an array?
3. How do you delete a section in MATLAB?
4. What is the delete command in MATLAB?

12
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B000324(022)

10 Compute y-coordinates of a straight line y=mx+c where slope of line m=0.5,


interceptc=-2andxcoordinates:x=0to 10for 0.5increments
Ans: >>x=[0:0.5:10];
>>y =x.* 0.5 +2 % y=mx + cwhere m=0.5c=2y

Columns1through7

2.0000 2.2500 2.5000 2.7500 3.0000 3.2500 3.5000

Columns8through14

3.7500 4.0000 4.2500 4.5000 4.7500 5.0000 5.2500

Columns15through21

5.5000 5.7500 6.0000 6.2500 6.5000 6.7500 7.0000

VIVA QUESTIONS :

1. What is the formula for slope in Matlab?


2. How do you find the slope of a line in Y MX C?
3. What is C in slope intercept form?
4. What is the y-intercept formula for two points?

13
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B000324(022)

11 Ploty=sinxwhere 0≤x≤10 ,Ploty = e -0.4sinx0 ≤x ≤10.


Ans: >>x=0:0.01:10;
>>y=sin(x);
>>plot(x,y)

>>x=0:0.01:10;
>>y=exp(sin(x).*(-0.4));
>>plot(x,y)

VIVA QUESTIONS :

1. How to plot in MATLAB with x and y?


2. How to plot a graph in MATLAB from data?
3. How to plot x 0 line in MATLAB?
14
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B000324(022)

12 Plot 4differentsignalinasinglefigurewithproperlabel.
Ans: >>x=0:0.01:10;
>>y1=exp(x);
>>y2=cos(x);
>>y3=sin(x);
>>y4=log(x);
>>figure
>>subplot(2,2,1),plot(x,y1,'r'),ylabel("Exp(x)"),xlabel("X")
>>subplot(2,2,2),plot(x,y2,'g'),ylabel("Cos(x)"),xlabel("X")
>>subplot(2,2,3),plot(x,y3,'b'),ylabel("Sin(x)"),xlabel("X")
>>subplot(2,2,4),plot(x,y4,'m'),ylabel("Log(x)"),xlabel("X")

VIVA QUESTIONS :

1. What is the plot signal function in MATLAB?


2. What is the use of plot in MATLAB?
3. What is a signal in MATLAB?
4. What are the types of plot that can be done in MATLAB?
5. What is a signal in MATLAB?

15
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B000324(022)

13 Assumeacarcompany;Productionof 6yearsfrom2010to2015isgivenas30000,
25000,40000,65000,45000 and 20000. Write the code to create a bar chart to
visualizethegiveninformation.
Ans: >>year=[2010:2015];
>>sales=[30000,25000,40000,65000,45000,20000];
>>bar(year,sales)
>>xlabel("Year")
>>ylabel("Sales")
>>title("YearWiseSalesDetails")

VIVA QUESTIONS :

1. What is the size of the bar in MATLAB?


2.What is the width of the bar chart in MATLAB?
3. What is the text size of colorbar in MATLAB?
4. What is the syntax of size in MATLAB?
5.What is colorbar function in MATLAB?

16
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B000324(022)

14 Determinationofrootsofagivenpolynomial&quadraticequations.
Ans: >> equation='x^2 - 7*x + 12 =

0'equation=

x^2-7*x+12 =0

>>

root=solve(equation)roo

t=

3
4

Coefficientrepresentationoffunction
>>x=roots([1,-7,12]) %x^2 -

7*x+12=0x=

4
3

17
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B000324(022)

18
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B000324(022)

15 Find the solution of linear algebraic equations in 2 variables, 3


variables.a.2x+3y =12;2x– 3y=0;
b.X+2y+3z=1;3x+3y +4z=1;2x+3y +3z=2
Ans: >>r=solve('2*x+3*y=12','2*x-3*y=0');
>>

r.xans

=3

>>

r.yans

=2

>>r=solve('x+2*y+3*z=1','3*x+3*y+4*z=1','2*x+3*y+3*z=2');
>>

r.xans

-1/2

>>

r.yans

=3/2

>>

r.zans

-1/2

19
>>symsx;
>>symsy;
>>symsz;
>>A=[1 2 3;3 34;23 3]; %CoefficientMatrixA
>>b=[1 ;1;2]; %KnownConstantVector
>>X=[x;y;z]; %UnknownVector
>>X=A\b %Solutionof

unknownvectorAx=bX=

-0.5000
1.5000
-0.5000

>>A*X %To check

solutionans =

1.0000
1.0000
2.0000

VIVA QUESTIONS :

1. How to solve two equations with three variables in MATLAB?


2.How do you solve two variable equations in MATLAB?
3. How do you define a variable in Matlab?
20
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B022324(022)

16 DeterminationofEigenvalueandEigenvectorformatrices.
Ans: >>x=rand(3) %Random

Matrixx=

0.8147 0.9134 0.2785


0.9058 0.6324 0.5469
0.1270 0.0975 0.9575

>>[A,D]=eig(x) %Eigen values and eigen

vectorsA=

0.6752-0.7134-0.5420
-0.7375-0.6727-0.2587
-0.0120-0.1964 0.7996

D=

-0.1879 0 0
0 1.7527 0
0 0 0.8399

VIVA QUESTIONS :

1.What is eigenvalue and eigenvector in Matlab?


2.What is the concept of eigenvalues and eigenvectors of a matrix?
3. How to find the eigen values of a matrix in MATLAB?

21
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B022324(022)

17 Writeascripttodraw aunit circle.


Ans: >>theta=linspace(0,2*pi,100);
>>x=cos(theta);
>>y=sin(theta);
>>plot(x,y)
>>axis('equal')

VIVA QUESTIONS :

1.What is the function to draw a circle in MATLAB?


2.How do you draw a unit circle in MATLAB?
3.Which command is used to draw a circle?

22
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B022324(022)

18 Writeafunctionfactorialtocomputethefactorialn!Foranyintegern.
Ans: %Createamfile.Saveasfactorial.m

function[result]=factorial(n)
%factorial(n)willcalculaten!result=1;
fori=1:n
result=result*i;
end
end

>>value=factorial(5) %Calling factorial

functionvalue=

120

VIVA QUESTIONS :

1. What is the function to calculate the factorial of n in matlab?


2.What is the function to calculate n factorial?
3. What is factorial method in Matlab?
4.What is the full factorial code in Matlab?
5.How to write function in MATLAB?

23
B-TECH3rdSemCSE
Software Laboratory (Sci
Lab/MATLAB)Code:B022324(022)

19 DevelopanyMatlabbasedapplication.
Ans: UsingImageProcessingToolbox

24
QUESTIONS BEYOND SYLLABUS

Experiment no. 1

AIM : Astudentgotmarks25,30,23,40,and27in5differentsubjects.Theuniversity wants to give grace


marks of 5 for each subject. Write thecodetocreateamarksvectoranddisplaytheoriginalmarksand
updatedmarks.

SOURCE CODE:

>>marks=[2530234027]

marks=

25 30 23 40 27

>>

new_marks=marks+5new_marks=

30 35 28 45 32

>>

25
Experiment no.2

AIM : InanInstitution,placement,andhigherstudydetailsareasfollows:
Year Placement Higher
Study
2017 60 40
2018 78 22
2019 75 25

Writethecodetocreateabarcharttovisualizethegiveninformation.

SOURCE CODE :
>>year=[2017:2019];
>>placement=[60;78;75];
>>higher_study=[40;22;25];
>>student_record=[placement,higher_study];
>>bar(year,student_record)
>>legend('Placement','HigherStudy')

26
EXPERIMENT NO. 3

AIM : In a city, 40% people speak Hindi, 20% speak Tamil, 30% speak
Hindiand10%speakMarathi.Writethecodetocreateapiecharttovisualizethegiveninformation.

SOURCE CODE :
>>data_set=[40,20,30,10];
>>labels={'Hindi','Tamil','Bengali','Marathi'};
>>pie(data_set,labels)

27

You might also like