×

### Let's log you in.

or

Don't have a StudySoup account? Create one here!

×

or

## Programming Notes

by: Neha Bhagirath

10

0

14

# Programming Notes BE1500

Neha Bhagirath
WSU

Get a free preview of these Notes, just enter your email below.

×
Unlock Preview

These are week 4 notes for programmingm, topics include fprintf and scripts and functions
COURSE
Intro to Programming
PROF.
TYPE
Class Notes
PAGES
14
WORDS
KARMA
25 ?

## Popular in Engineering and Tech

This 14 page Class Notes was uploaded by Neha Bhagirath on Tuesday June 7, 2016. The Class Notes belongs to BE1500 at Wayne State University taught by Tonya Whitehead in Spring 2016. Since its upload, it has received 10 views. For similar materials see Intro to Programming in Engineering and Tech at Wayne State University.

×

## Reviews for Programming Notes

×

×

### What is Karma?

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 06/07/16
­last resort, use else statement. Cannot put anything after the “else” expression or it won’t read it    ­only “if” and “end” are needed ­ the “elseif” and and “else” are not NEEDED      >> %Day 7 MATLAB examples  >> a=10;b=15;c=20;  >> x=a<b    x =         1    >> y=a>c||b<c    y =         1    >> %one means yes, zero means no   >> z=a>c&&b<c    z =         0    >> %these are 3 logical operators  >> v=x&y    v =         1    >> %if x is true and y is true, you should get a true for v as well   >> %string compare syntax is "strcmp('Yes','No')  >> %ex. s1='upon';s2={'Once','Upon','A','Time'};tf=strcmp(s1,s2)  >> s1='upon';s2={'Once','Upon','A','Time'};tf=strcmp(s1,s2)    tf =         0     0     0     0    >> %It's comparing each thing and saying yes this is true (1) or no this is false (0)  >> %example below  >> strcmp('Test','test')    ans =         0    >> %the above just asked MATLAB if capitalized test is different than lowercase test and it gave  false because that is not true   >> %examples with if­else statements  ­there are 2 inputs we can use in our script: a string or a number   ­if you put:  strcmp(‘trig,’sine’) it compares your input named ‘trig’ to the sine function, and if you input sine, it  will execute the command          In class exercise:  Answer:    trig=input('Enter a trig function,'s​;%be sure to include the string indicator  x=[0:pi/2:2*pi];%X values for the plot   i strcmp(trig,'sine)%will run if sine is entered      y=sin(x)%creates the y values for the plot       plot(x,y%plots the values of x vs y   elsei strcmp(trig, 'cosine) %will run if cosine is entered      y=cos(x);      plot(x,y),  elsei strcmp(trig,'tangent')%will run if tangent is entered      y=tan(x);      plot(x,y),  else   % runs if none of the other cases are met       disp'Please Try Again'​)  end  titl'Lecture 6 Exercise 1'​)  xlabel('Angle')  ylabel('y axis)        OR       trig=input('Enter A Trig Function: ​s'; %be sure to include the string indicator , the s  x=[0 2*pi];  i trig=='sin(x %put single quotes otherwise it will take sinx as a vector and compare the 'trig'  variable to that      f=@(x)sin(x)      fplot(f,x)  elsei​trig=='cos(x)'      f1=@(x)cos(x)      fplot(f1,x)  else trig=='tan(x)'      f2=@(x)tan(x)      fplot(f2,x)  end      Day 8  ­with a function, you cannot RUN the script. You have to put the first line in the command window  instead  ­the reason we make functions is that we can call chunks of code elsewhere without having to  rewrite it again     ­in the following pic, if you put an elseif, then it’ll look at the ~=, but because you have just an  else, it didn’t even look at what was after the else (also with “otherwise” it won’t look at what is  after that)            Another way of doing an elseif, generally used for strings instead of numbers:    Example:  The ‘s’ is there because it is a string and not a number            Exercise:      BUT you have to make a function so:  ­there is one input and zero output arguments  (now this will make a graph when you type in A1)  (dset is a variable name to indicate something)  (don’t need input since it is a function)        Question:

×

×

### BOOM! Enjoy Your Free Notes!

×

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

Steve Martinelli UC Los Angeles

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Anthony Lee UC Santa Barbara

#### "I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

Jim McGreen Ohio University

Forbes

#### "Their 'Elite Notetakers' are making over \$1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!
×

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com