Presentation is loading. Please wait.

Presentation is loading. Please wait.

MATLAB LABORATORY SESSION

Similar presentations


Presentation on theme: "MATLAB LABORATORY SESSION"— Presentation transcript:

1 MATLAB LABORATORY SESSION
SEE1012: Introduction to Electrical Engineering MATLAB LABORATORY SESSION

2 HELP To access MATLAB help or documentation >> help Or
To access help on specific topic e.g. sin(x) >> help sin >> doc sin

3 PLOT MATLAB provides a number of plots Getting help on plot
>> doc plot >> doc subplot >> doc plot3 >> doc pie >> doc polar >> doc bar After the CANCER project, the next innovation was the SPICE program. SPICE stands for Simulation Program with Integrated Circuit Emphasis. This new acronym was created from the fact that many of the components being placed on the new integrated circuit were becoming smaller than the discrete components themselves. With this in mind, the SPICE creators wanted to save money by not having to manufacture chips to test the circuits. The next logical step was to let a computer do the testing for them. By not building the physical circuit, the designers can save a lot of time and money.

4 PLOT MATLAB provides a number of plots Single plot e.g.
>> x=0:pi/50:4*pi >> plot(x,sin(x)) After the CANCER project, the next innovation was the SPICE program. SPICE stands for Simulation Program with Integrated Circuit Emphasis. This new acronym was created from the fact that many of the components being placed on the new integrated circuit were becoming smaller than the discrete components themselves. With this in mind, the SPICE creators wanted to save money by not having to manufacture chips to test the circuits. The next logical step was to let a computer do the testing for them. By not building the physical circuit, the designers can save a lot of time and money.

5 PLOT Double line on single graph e.g. >> x=0:pi/50:4*pi
>> plot(x,sin(x),x,cos(x)) After the CANCER project, the next innovation was the SPICE program. SPICE stands for Simulation Program with Integrated Circuit Emphasis. This new acronym was created from the fact that many of the components being placed on the new integrated circuit were becoming smaller than the discrete components themselves. With this in mind, the SPICE creators wanted to save money by not having to manufacture chips to test the circuits. The next logical step was to let a computer do the testing for them. By not building the physical circuit, the designers can save a lot of time and money.

6 PLOT Multiple separate graphs e.g. >> x=0:pi/50:4*pi
>> subplot(1,2,1) >> plot(x,sin(x)) >> subplot(1,2,2) >> plot(x,cos(x)) After the CANCER project, the next innovation was the SPICE program. SPICE stands for Simulation Program with Integrated Circuit Emphasis. This new acronym was created from the fact that many of the components being placed on the new integrated circuit were becoming smaller than the discrete components themselves. With this in mind, the SPICE creators wanted to save money by not having to manufacture chips to test the circuits. The next logical step was to let a computer do the testing for them. By not building the physical circuit, the designers can save a lot of time and money.

7 PLOT 3 dimensional plot e.g. plot of a helix
>> t = 0:pi/50:10*pi; >> plot3(sin(t),cos(t),t) >> grid on axis square After the CANCER project, the next innovation was the SPICE program. SPICE stands for Simulation Program with Integrated Circuit Emphasis. This new acronym was created from the fact that many of the components being placed on the new integrated circuit were becoming smaller than the discrete components themselves. With this in mind, the SPICE creators wanted to save money by not having to manufacture chips to test the circuits. The next logical step was to let a computer do the testing for them. By not building the physical circuit, the designers can save a lot of time and money.

8 PLOT MATLAB can draw a sphere >> sphere >> axis equal
After the CANCER project, the next innovation was the SPICE program. SPICE stands for Simulation Program with Integrated Circuit Emphasis. This new acronym was created from the fact that many of the components being placed on the new integrated circuit were becoming smaller than the discrete components themselves. With this in mind, the SPICE creators wanted to save money by not having to manufacture chips to test the circuits. The next logical step was to let a computer do the testing for them. By not building the physical circuit, the designers can save a lot of time and money.

9 PLOT MATLAB can draw other shapes as well.
>> [x,y] = meshgrid(-16:1.0:16); >> z = sqrt(x.^2 + y.^ ); >> surf(z) >> shading interp After the CANCER project, the next innovation was the SPICE program. SPICE stands for Simulation Program with Integrated Circuit Emphasis. This new acronym was created from the fact that many of the components being placed on the new integrated circuit were becoming smaller than the discrete components themselves. With this in mind, the SPICE creators wanted to save money by not having to manufacture chips to test the circuits. The next logical step was to let a computer do the testing for them. By not building the physical circuit, the designers can save a lot of time and money.

10 Solving Equations MATLAB provides many ways of solving equations
Example Lets try solving two equations y=x2 and y=x+4 Get help on ‘solve’ >> doc solve

11 Solving Equations To solve the two equations
>> S = solve('y-x^2','y-x-4’)

12 Solving Equations To solve the two equations
>> s = solve('y-x^2','y-x-4’) This will flag an error. Why? >> s = solve('y-x.^2','y-x-4’) >> s.x >> x=double(s.x) >> y=double(s.y)

13 Solving Equations Lets see the intersection of the two graphs
>> x=-2:.1:3 >> plot(x,x.^2,x,x+4)

14 Differentiation MATLAB is able to differentiate an equation
Let y=x4+2x3+3x2+4x+5 >> y=[ ] >> diff(y)

15 FUNCTION Function can be created using m-files.
The name of the file must be similar to the name of the function. Create a new file Save the file as not_a_function.m in MATLAB subdirectory

16 Content of not_a_function
Content of not_a_function.m file subplot(2,2,1) plot(x,sin(x)) subplot(2,2,2) plot(x,sin(x+pi/2)) subplot(2,2,3) plot(x,cos(x)) subplot(2,2,4) plot(x,cos(x+pi/2))

17 FUNCTION From the MATLAB workspace type : >> x=0:pi/50:4*pi;
>> not_a_function

18 FUNCTION A function can be created by naming a file similar to the name of the function. Example To create a function, open not_a_function.m Save the file as myfunction.m in MATLAB subdirectory

19 Content of myfunction.m file function myfunction(x) % This is my first function in MATLAB % I hope I will use it a lot later % % See you then subplot(2,2,1) … plot(x,cos(x+pi/2))

20 FUNCTION From the MATLAB workspace type : >> clear x
>> x=0:pi/50:4*pi; >> myfunction(x)

21 Symbolic Toolbox To use symbolic toolbox, type >> help syms
To declare s as a variable >> syms s

22 Symbolic Toolbox To differentiate a function in s
>> d=diff(3*s^2+4*s+5) To integrate a function in s >> i=int(d)

23 THE END


Download ppt "MATLAB LABORATORY SESSION"

Similar presentations


Ads by Google