7 views

Uploaded by jayeshruikar

- Solution Sheet0 2010
- Time Series Lecture 4
- 2010-04-26 Inverse and Exponential Function Topic List
- Glycerin-Water Viscosity Paper _sent to Ind Eng Chem Res
- MSD System
- 10.1.1.120
- Bit–Error Rate Evaluation for MC-CDMA
- F4 mock LQ _Ans_
- alg2b u2l7 graphing exponential functions
- Final BS, MS, PhD Terminal Date Sheet Fall 2015
- Huebner 3
- tarea4matricialmat
- tristanm sethn spencerb alg-2 pr6 pw5
- 42453412345.pdf
- Slides - Piasecki, Jarosław
- alg1 chapter5 test
- Absolute Value Guess Slips
- Newsletter
- create equation present
- Logarithmic and Exponential Functions

You are on page 1of 5

('program for calculation root of ploy.') a=input('enter 1st coefficient'); b=input('enter 2nd coefficient'); c=input('enter 3rd coefficient'); x=-b/(2*a); y= (sqrt(b*b-4*a*c))/(2*a); r1=x+y; r2= x-y; fprintf('first root = %f \t second root = %f \n', r1,r2) OUTPUT: program for calculation root of ploy. enter 1st coefficient2 enter 2nd coefficient3 enter 3rd coefficient6 first root = -0.750000 second root = -0.750000

**Saving output to a file using fprintf command
**

PROGRAM 2: %program for calculating exponentiation of value of x from 1 to 11 % save the output to kalpesh.txt file using fprintf command x = 0:1:11; y = [x; exp(x)] fid = fopen('kalpes.txt', 'w'); fprintf(fid,'Prog. for e^x for several x\n') fprintf(fid,'val of x \tval of exp\n') fprintf(fid, '%6.2f \t\t%2.4f\n', y); fclose(fid)

**output: is in the file named as kalpes.txt
**

Prog. for e^x for several x val of x val of exp 0.00 1.0000 1.00 2.7183 2.00 7.3891 3.00 20.0855 4.00 54.5982 5.00 148.4132 6.00 403.4288 7.00 1096.6332 8.00 2980.9580 9.00 8103.0839 10.00 22026.4658 11.00 59874.1417

750000 .'val of x \tval of x^2\n') fprintf(fid. end Utilising it in the script file x=input('enter 1st coefficient'). a.b.txt file x = 0:1:11. enter 1st coefficient2 enter 2nd coefficient3 enter 3rd coefficient6 first root = -0.750000 second root = -0. fclose(fid) output: is in the file named as bsps. y= (sqrt(b*b-4*a*c))/(2*a).*x] fid = fopen('bsps. fprintf(fid.y.txt'. x. 'w'). for x^2 for several x\n') fprintf(fid. fprintf('first root = %f \t second root = %f \n'. y=input('enter 2nd coefficient').z ).b) OUTPUT: program for calculation root of ploy. z=input('enter 3rd coefficient'). r2= x-y. y = [x.'Prog.c ) x=-b/(2*a). y). '%d \t \t%d\n'.txt Prog. b ] = root_jayesh( x. r1=x+y. [ a. r2 ] = root_jayesh( a.PROGRAM 3: %program for calculating square of value of x from 1 to 11 % save the output to bsps. for x^2 for several x val of x val of x^2 0 0 1 1 2 4 3 9 4 16 5 25 6 36 7 49 8 64 9 81 10 100 11 121 Creating function file: PROGRAM 4: Create a user defined function with name root_jayesh which determine roots of ploynomial of order 2 with two output and three input and use it in script file function [ r1.

age = input ('Enter hers/his age in years :'). elseif (age < 13) disp('Child'). else disp('Senior').'). elseif (age < 1) disp('Baby'). end OUTPUT: Enter an age : 20 Adult Switch case PROGRAM 7 %prog for mathematical operation to be calculating with switch loop x=input('enter 1st no.').name) else fprintf ('%s is not eligible to vote\n'.z) case 2 z=x-y. if ((age < 0)|(age >= 120)) disp('Error').'s'). two no. %using . switch op case 1 z=x+y. y=input('enter 2nd no. fprintf('addition = %f'. elseif (age < 18) disp('Teenager'). if age>=18 fprintf ('%s is eligible to vote\n'.if Statement PROGRAM 5: %prog for entering name and age of person and display whether to eligible to %vote or not. disp('enter 1 for addition') disp('enter 2 for substarction') disp('enter 3 for multiplition') disp('enter 4 for division') op=input('enter the operation= ').name) end OUTPUT: Enter the citizen full name :abcd Enter hers/his age in years :15 abcd is not eligible to vote PROGRAM 6: %program to asks the user for an age and then classifies it age=input('Enter an age : '). elseif (age < 60) disp('Adult'). name = input ('Enter the citizen full name :'.

fprintf('substraction = %f'.000000 Switch case with string PROGRAM 8 % program for traffic light controller using switch case with string disp(' **************** Traffic light condition *****************') light = input('Enter the following traffic light color: red. green. count=0. fprintf('multiplication = %f'.'s') switch light case'green' disp( 'It is safe to pass') case'red' disp('It is not safe to pass') case'yellow' disp('Proceed with caution') otherwise disp('Light is not functioning') end OUTPUT: **************** Traffic light condition ***************** Enter the following traffic light color: red. using while loop x= input('enter the no (end in 0 )'). .z) otherwise disp('wrong operation') end OUTPUT: enter 1st no.z) case 3 z=x*y. others:red light = red It is not safe to pass While Loop PROGRAM 9 % prog for calculating sum of numbers and average of the no.20 enter 2nd no.z) case 4 z=x/y.30 enter 1 for addition enter 2 for substarction enter 3 for multiplition enter 4 for division enter the operation= 3 multiplication = 600. green. fprintf('division = %f'. sum=0. while x~=0 sum=x+sum. others:'. yellow. yellow.

j) + B(i. 17 18 19] C=zeros(3).000000.C(i.sum. x= input('enter the no (end in 0 )').j) . for i=1:3 for j=1:3 C(i. 14 15 16.000000 Using FOR LOOP PROGRAM 10 % program for addition of 3x3 matrix using for loop A = [1 2 3. fprintf ('no entered = %d. count.j)) end fprintf('\n') end OUTPUT: A = 1 4 7 B = 11 12 13 14 15 16 17 18 19 addition 0f matrix is= 12 14 16 18 20 22 24 26 28 2 5 8 3 6 9 . sum=%f. Average= %f'. end ave= sum/count. 7 8 9] B = [11 12 13. sum=60. Average= 20.j) = A(i. 4 5 6. end end % to display output fprintf('addition 0f matrix is= \n') for i=1:3 for j=1:3 fprintf('%d\t'.ave) OUTUT: enter the no enter the no enter the no enter the no no entered = (end in 0 )10 (end in 0 )20 (end in 0 )30 (end in 0 )0 3.count= count+1.

- Solution Sheet0 2010Uploaded bySha Gordfrr
- Time Series Lecture 4Uploaded byJason Wu
- 2010-04-26 Inverse and Exponential Function Topic ListUploaded bysamjshah
- Glycerin-Water Viscosity Paper _sent to Ind Eng Chem ResUploaded bySulthoni Mukhlis Kurniawan
- MSD SystemUploaded byfaizrumman
- 10.1.1.120Uploaded bySam Sch
- Bit–Error Rate Evaluation for MC-CDMAUploaded byaravindhana1a1
- F4 mock LQ _Ans_Uploaded byxpec2002
- alg2b u2l7 graphing exponential functionsUploaded byapi-276774539
- Final BS, MS, PhD Terminal Date Sheet Fall 2015Uploaded byMunir Aslam
- Huebner 3Uploaded byyoodacx
- tarea4matricialmatUploaded bypablojaramora
- tristanm sethn spencerb alg-2 pr6 pw5Uploaded byapi-357616428
- 42453412345.pdfUploaded byarsfdasf
- Slides - Piasecki, JarosławUploaded byrafaelvanhoz
- alg1 chapter5 testUploaded bymeanpr
- Absolute Value Guess SlipsUploaded byblanchierd
- NewsletterUploaded byBriLynn83
- create equation presentUploaded byapi-300252239
- Logarithmic and Exponential FunctionsUploaded byKandice Fyffe
- Acv_Algebra_2018_2Uploaded byMarcelino Lopez Causo
- Simultaneous Equations Worksheet #01, Algebra revision from GCSE Maths TutorUploaded bygcsemathstutor
- II Sem Mathematics All SolutionsUploaded byMrityunjoy Dutta
- practice k 3-5Uploaded byapi-296726470
- Monday Nov19 1-16odd and 29-38oddUploaded bystanleychang617
- math syllabus for m3Uploaded byapi-253466076
- 1 - Computational Mode CaltechUploaded byEthan Anthony
- Maxima BookUploaded bykyryix
- translate algebraic expressions 2Uploaded byapi-288922072
- 205 Quiz 3 Solutions Spr12Uploaded byichigosensei

- Aim, Objective, MethodologyUploaded byjayeshruikar
- UntitledUploaded byjayeshruikar
- image fusion using complex waveletUploaded byjayeshruikar
- Special Issue on LargScale Learning for Media UnderstandingUploaded byjayeshruikar
- NLMSUploaded byjayeshruikar
- Xilinx ISE 9.2i -Quick Start TutorialUploaded bygeorgemoldovan
- Wavelet Transforms Full ReportUploaded byjayeshruikar
- IMAGE TOOL & IT’S APPLICATIONUploaded byjayeshruikar
- Simple 4_1 MUXUploaded byjayeshruikar

- Johor Add Maths P2 2017Uploaded byKhor Han Yi
- Lecture 7Uploaded byDanger Cat
- unit circle projectUploaded byapi-325674496
- Coordinate FramesUploaded byadrianwtx90
- Programming TutorialUploaded byhelover
- HAAR WAVELET QUASI-LINEARIZATION APPROACH FOR SOLVING LANE EMDEN EQUATIONSUploaded byTJPRC Publications
- mathematics 1 - workbook - draft-2Uploaded byapi-186580085
- Study of Zoning an Operational Research ApproachUploaded byESSENCE - International Journal for Environmental Rehabilitation and Conservaion
- Copy of Pages From New Math Book_Part2-4Uploaded byNhocticaro Nhoc
- AndersP LicUploaded byalexanderkale
- Reinforcement Learning for Traffic Control System: Study of Exploration Methods using Q-learningUploaded byIRJET Journal
- Begin MatrixUploaded byeliceokj
- Class 12 - Control Charts for Attributes1 (2 of 2).pdfUploaded byMatthew Smith
- Prospectus 2015 16Uploaded bySukumar Mani
- counting on multiplicationUploaded byapi-288880257
- Primary Calculator Project ProposalUploaded byDavid Chua
- Scientific WorkPlace Demonstration DocumentUploaded bygeeorgi23
- Optimization Modeling With LingoUploaded byjysung
- The Unreasonable Effectiveness of My Self-Experimentation by Seth RobertsUploaded byBryan Castañeda
- Lesson Plan 2017Uploaded byAlina-Arsaluis Cretu
- Mathematic - K to 12 Curriculum GuideUploaded byBlogWatch.ph
- gscienceUploaded byVishal Kumar
- Question 11Uploaded bySuresh Prasad
- 09_chapter2Uploaded bySyEd Mohammed Ifrahim
- cgUploaded byShanmugapriyaVinodkumar
- S2_sampleUploaded byvc94
- Mathematical and Scientific SymbolsUploaded byEm Bi Cuong
- Classical Geometry - Danny CalegariUploaded byde_jack
- Power Flow EquationsUploaded byJose A. Regalado Rojas
- Year 7 Basic Algebra and Graphing Practice TestUploaded bySerene Lim