🌐
MathWorks
mathworks.com › matlab › mathematics › elementary math › arithmetic operations
power - Element-wise power - MATLAB
C = power(A,B) is an alternate way to execute A.^B, but is rarely used. It enables operator overloading for classes. ... Create a vector, A, and square each element. ... Create a matrix, A, and take the inverse of each element. ... An inversion of the elements is not equal to the inverse of ...
Discussions

How to put trigonometric numbers as a power in matlab - Stack Overflow
I want to make a graph with this function in matlab in space [-2,2]. Because I am new (really new actually) in matlab, I am struggling, especially with the first part of the function, the one with ... More on stackoverflow.com
🌐 stackoverflow.com
Raising a matrix to a power
I want to raise the Tr value to the power of 1/2. I keep getting the same error. More on mathworks.com
🌐 mathworks.com
2
0
September 7, 2019
raise power to power in title
Hi~ I wanna write a title to a graph this way >> y = x * e^(- x^2 / 2 ) title(' y = x*e^(- x^2 / 2) ') writes e as base and only ( as exponent title(' y = x*e^-^x^2^/^2 ') shows e^(-x2/2) not... More on mathworks.com
🌐 mathworks.com
1
0
October 15, 2020
How to raise a decimal numbers as power of A??
How to raise a decimal numbers as power of A??. Learn more about matlab, digital image processing MATLAB, MATLAB and Simulink Student Suite More on mathworks.com
🌐 mathworks.com
2
0
April 8, 2020
🌐
MathWorks
mathworks.com › matlab › mathematics › elementary math › exponents and logarithms
Powers and Exponentials - MATLAB & Simulink
When you raise a scalar to the power of a matrix, MATLAB uses the eigenvalues and eigenvectors of the matrix to calculate the matrix power. If [V,D] = eig(A), then ... The matrix exponential is a special case of raising a scalar to a matrix power. The base for a matrix exponential is Euler's ...
🌐
CK-12 Foundation
ck12.org › all subjects › cbse math › laws of exponents › how do you use exponents in matlab?
Flexi answers - How do you use exponents in MATLAB? | CK-12 Foundation
September 11, 2025 - Here’s how it works: Basic Usage: To raise a number to a power, you write it like this: result = base^exponent; For example, to calculate @$\begin{align*}2^3\end{align*}@$: result = 2^3; % This will give you 8 Using Variables: You can also use variables: base = 5; exponent = 2; result = ...
🌐
YouTube
youtube.com › watch
how to take power of a number in matlab | raised to the power function in matlab - YouTube
In this tutorial you will learnhow to take power of a number in matlab,how to take power of an integer in matlab,how to find the power of an integer in matla...
Published   September 16, 2020
🌐
How to use OpenCV
opencvhelp.org › tutorials › matlab › how-to-raise-to-a-power-in-matlab
A Comprehensive Guide to Power Operations in MATLAB
MATLAB provides an operator called ‘.’ that operates similarly to the division operator but can specifically handle vectors and matrices as arguments. It is a versatile tool when dealing with numerical operations involving vectors or matrices where efficient and concise programming is desired. Example: To raise a vector [1, 2, 3] to the power of 2, you can use the ‘.'^ operator: ... In summary, there are several ways to raise numbers and various data types to powers in MATLAB.
Find elsewhere
Top answer
1 of 2
4

Let's cover all the points in no particular order:

  • The e is known as Euler's constant, where e ~ 2.71828...
    Something like ex, i.e. raising e to the power of x is known as the exponential function. While you could in theory compute e and then use the power operator (^ in matlab) to raise e to that power accordingly, this is in fact a less precise way of calculating the exponential function, and therefore matlab provides the exp function for that purpose. If you pass an array [x1, x2,...] to exp, it will perform this function "elementwise", and return [ex1, ex2,...] appropriately.

  • The sin function, similarly, if given an array of numbers, will calculate the sin for each of those numbers, and return an array of the same shape as its input.

  • You could use fplot with an anonymous function as Neo suggested, but I find that beginners find that confusing. So instead I would suggest you create an array of values between [-2,2], and obtain the value of y for each of them, which in matlab can be done as a single operation because it's good at working with arrays and performing such 'vectorized' operations:

    Copyx = [-2:0.1:2];  % Create an array of values from -2 to 2, with a step of 0.1
                     % Note: the ';' at the end suppresses output; if you want to
                     % see the contents of your array, remove it at the end.
    
  • Now that you have your array x you can perform operations on it. By convention, matlab uses "dot-operators" to denote "elementwise" operations, as opposed to 'undotted' ones denoting primarily "matrix" operations. Therefore to raise all elements of the array x to the power of 6, you would do x .^ 6
    With that in mind, you can now calculate your f(x) for each point in the array x, by using elementwise operations:

    Copyy = exp( sin(x).^3 ) + x.^6 - 2*(x.^4) - x.^3 - 1;
    

    The result is an array y of the same size as x.

  • You can now plot this using the plot command, which takes two arrays of the same size and plots all points in the first array against their equivalent points in the second array, as (x,y) pairs:

    Copyplot( x, y );
    

Output:

As you can see, matlab 'connects' the points by default. If you wanted to see just the individual points of your array instead, you can specify this as the third argument:

Copyplot(x, y, 'o');

Type help plot at the matlab terminal to see more options for the plot command.


PS: The above plots were made in octave rather than in matlab, because I don't have matlab at home. Your own plots may look slightly different.

2 of 2
3

For a simple one-liner you could use:

Copyfplot(@(x) exp(sin(x).^3) + x.^6 - 2*x.^4 - x.^3 - 1, [-2 2]);

See fplot.

🌐
Stack Overflow
stackoverflow.com › questions › 43749010 › how-to-raise-variable-to-a-power-without-using
matlab - how to raise variable to a power without using "^"? - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Basically, the only way I know to raise a variable to a power is by writing it like this (a^b).
🌐
MathWorks
mathworks.com › matlabcentral › answers › 529583-simulink-raise-model-output-to-1-5-power
Simulink raise model output to 1.5 power - MATLAB Answers - MATLAB Central
May 21, 2020 - https://www.mathworks.com/matlabcentral/answers/529583-simulink-raise-model-output-to-1-5-power#answer_438903 ... You need to use the Math block and select the 'pow' function. Alternatively, you can use the Fcn block and use u(1)^1.5 if you ...
🌐
MathWorks
mathworks.com › matlabcentral › answers › 580848-raise-a-scalar-to-a-descending-series-of-powers-in-an-array
Raise a scalar to a descending series of powers in an array - MATLAB Answers - MATLAB Central
August 17, 2020 - So since you want to perform elementwise matrix powers, use the .^ operator instead of the ^ operator. ... Sign in to comment. ... https://www.mathworks.com/matlabcentral/answers/580848-raise-a-scalar-to-a-descending-series-of-powers-in-an-...
🌐
Reddit
reddit.com › r/matlab › i'm having some trouble with exponents. pls help!
r/matlab on Reddit: I'm having some trouble with exponents. Pls help!
December 14, 2022 -

So, the attached image is what I need to plot. I've written out some code as well, but I'm having some trouble raising e to the exponent.

Any help to my code or how to approach the problem is much appreciated.

The code:

t=0:0.1:1;

a=3;

f = 5;

w = 2*pi*f;

phi = -pi/4;

y1=a*exp(t*(-3))*cos((w.*t)+phi);

plot(t,y1)

The error message I get looks like this:

Top answer
1 of 1
1
Hi @Carlos Thanks for the update. Which specific method did you use? Was it ? Regardless of the method employed, you should be aware that even if the simulation runs smoothly, it does not necessarily mean that the result is valid according to the laws of physics. Therefore, you should carefully verify whether the result makes sense. For example, in a common mechanical engineering problem where the friction or drag force model exhibits nonlinear behavior and is proportional to velocity, students often use the power law when the object is moving through non-Newtonian fluids. What would happen if the velocity is a negative value? Mathematically, this results in a complex output. However, the negative sign of the velocity does not imply a "negative" amount. Rather, it indicates the opposite direction of velocity when the reference frame is defined in the model. v = linspace(-2, 2, 4001); k = 1; lambda = 1.2; Fd = - k*(v.^lambda); figure plot(v, Fd), hold on plot(v, -v, '--'), hold off grid on, ylim([-2.5, 2.5]) legend('Nonlinear Friction', 'Linear Friction') title('Case 1: Power law') xlabel('v') ylabel('F_{d}') To avoid complex outputs, students typically use the absolute value operator. However, do the magnitude and direction of the friction force make sense? Fd = - k*(abs(v).^lambda); figure plot(v, Fd), hold on plot(v, -v, '--'), hold off grid on, ylim([-2.5, 2.5]) legend('Nonlinear Friction', 'Linear Friction') title('Case 2: Power law with absolute value') xlabel('v') ylabel('F_{d}') To ensure the inverse symmetric property in the nonlinear friction model, the signum function can be used. Fd = - k*(abs(v).^lambda).*sign(v); figure plot(v, Fd), hold on plot(v, -v, '--'), hold off grid on, ylim([-2.5, 2.5]) legend('Nonlinear Friction', 'Linear Friction') title('Case 3: Absolute power law with sign function') xlabel('v') ylabel('F_{d}')
🌐
Unisa
lo.unisa.edu.au › mod › book › tool › print › index.php
MATLAB | learnonline
Firstly, we will perform simple ... ^ (raise to a power, or exponentiation). We will also include parentheses (brackets). Enter the MATLAB Command Window. Type in each of the following arithmetic expressions after the >> prompt and press the Enter key at the end of each line.