• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 14 pages
Exam (elaborations)

Engineering 102 Final Exam Already Passed

Document preview thumbnail
Preview 2 out of 14 pages

Engineering 102 Final Exam Already Passed == equal to = greater than or equal to = less than or equal to ~= not equal to if statements if elseif else end && and || or input function x=input('enter number of whatevern') fprintf fprintf('the number of apples is %.1fn', x) x=number of apples clc clears command window clear clears workspace custom functions [output,output]=functionname(input,input) function [output,output]=functionname(input,input) %functionname is a function that does this %input arguments are &output arguments are equations that convert end sin(#) sine in radians sind(#) sine in degrees string b='Paige' fprintf('my name is %sn', b) d=[1 2 3 4 5] 1 x 5 vector 1 row 5 columns d=[1 2 3 4 5; 1 2 3 4 5] 2 x 5 matrix 2 rows 5 columns h=[1 2 3 4 5] h(3) displays the 3rd number, 3 h=[1 2 3; 12 14 12] h(2,2) displays number in 2nd row, 2nd column, number 14 add numbers to a vector h=[1 2 3 4 5 6] h(8)=8 will show up: h= 1 2 3 4 5 6 0 8 vector=[x:y:z] x=first number y=increment z=last number linspace command for vectors linspace(first number, last number, number of elements) mean(x) average of x if x is a vector, length(x) displays the number of elements in the vector Matrix(r,c) r=row # c=column # Matrix [vector; vector; vector] use . when multiplying, dividing, raising to an exponent matrices subplotting (2 plots 1 figure) figure x=1:1:10 y1=x+2 y2=x+3 subplot(2,1,1) %2 by 1 matrix of plot 1 plot(x,y1) xlabel('x') ylabel('y1') title('y vs x') grid subplot(2,1,2) %2 by 1 matrix of plot 2 plot(x,y2) xlabel('x') ylabel('y2') title('y vs x') grid plotting one figure x=1:1:10 y=x+2 plot(x,y) xlabel('x') ylabel('y') title('y vs x') grid plotting 2 lines in 1 figure figure x=1:1:10 y1=x+2 y2=x+3 hold on plot(x,y1) plot(x,y2) hold off add labels and grid y=zeros(2,3) displays a 2 row 3 column matrix of 0s y=ones(3,4) displays a 3 row 4 column matrix of 1s y=4*ones(3,5) displays a 3 row 5 column matrix of 4s axis on plots axis([xmin,xmax,ymin,ymax]) for loops for vector (number of times it will run) commands (ex. equations or disp) end for a=1:4 y(a)=a+2 end disp(y) will display a vector y=[3 4 5 6] p=1 for x=[1 2 3 4 5] y(p)=x+2 p=p+1 end disp(y) disp(x+1) y= [3 4 5 6 7] 6 while end loops a=1 while a=5 disp('wvu') a=a+1; end wvu will display 5 times randi function randi(2,3) creates 2 rows 3 column matrix of random (integer) numbers randi([3,9],2,3) creates 2 row 3 column matrix of numbers 3 through 9 nested for-end loops m=[1 2 3 4; 5 6 7 8] for r=1:2 %rows 1-2 for c=1:4 %columns 1-4 if m(r,c)6 %if any number is less than 6 m(r,c)=100 %replaces the number with 100 end end end disp(M) basically, replaces any number less than 6 with 100 while loop example of how many times the number was something g=[1 2 3 4 5 6 7] p=1; %position in vector counter=0 while p=length(g) if g(p)=4 counter=counter+1 end p=p+1; end counter equals the number of times g was larger or equal to 4 m=[1 2 3 4 5 6] x=length(m) what does x equal x=6 series problem m=input('Enter the number of terms in the seriesn'); sum=0; for n=0:m term=((-1/3)^n)/(2*n+1); sum=sum+term; end final=sqrt(12)*sum for vs while loops use for when you know how many times you want to run the loop 3D plotting figure t=1:1:10 x=t+1 y=t+2 z=t+3 plot3(x,y,z) grid xlabel('x') ylabel('y') zlabel('z') symbolic math syms x y z before ALL symbolic math equations syms x int(x) integrates equation x syms x y [output, output]=solve('equation, equation') [x,y]=solve('3*x=7, 4/6*x=90') solves multiple equations syms x factor(x^2-2*x+3) factors equation p=[1 2 3 5 6 7; 2 3 4 6 8 8] p(1,2)=[10] replaces the number in row 1 column 2 with the number 10 h=[1 2 3; 4 5 6] h(:,2)=[] deletes the numbers in row 1 column 2 therefore it will display h=[1 3; 4 6] exp(10) on matlab equals e^10 log(10) on matlab equals ln(10) log10(200) on matlab equals log(200)


Document information

Uploaded on
December 17, 2023
Number of pages
14
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers
$9.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
StellarScores
4.0
(522)
Sold
2025
Followers
867
Items
21171
Last sold
1 day ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions

Whoops! We can’t load your doc right now. Try again or contact support.