MATLAB Answers

## How can i plot function 2^x ??

Asked by Rolando Gutierrez

### Rolando Gutierrez (view profile)

on 27 Jun 2014
Latest activity Edited by madhan ravi

### madhan ravi (view profile)

on 14 Oct 2018
Accepted Answer by Ken Atwell

### Ken Atwell (view profile)

Sorry im a beginner, but if I got
X=0:0.1:3
Y=2^x
Plot(X,Y)
Why wont matlab plot it? And how do I solve it? Thanks

#### 0 Comments

Sign in to comment.

## 1 Answer

### Ken Atwell (view profile)

Answer by Ken Atwell

### Ken Atwell (view profile)

on 27 Jun 2014
Accepted Answer

You've almost got it. Two things to fix:
1. MATLAB is a case-sensitive language (that upper and lower case matters), so you must use upper-case "X" consistently, and "plot" is all lower case.
2. The "^" (raise to the power) operator is for square matrices. To computer a per-element raise to the power, use ".^" instead.
X=0:0.1:3
Y=2.^X
plot(X,Y)

madhan ravi

### madhan ravi (view profile)

on 14 Oct 2018
Accepted by madhan ravi since the OP didn’t accept the answer

Sign in to comment.