Is x a scalar? If so, then you write it as x^2. Is x a vector? Then, assuming you want to perform an element-wise squaring, you use x.^2. If you are asking this question, you REALLY need to be reading the getting started tutorials - the Onramp tutorials are a good place to start. There are also multiple MATLAB tutoring sessions on Youtube to watch. Finally, when you get an error. then show what you did. Show the COMPLETE error message, thus everything in red. Otherwise we need to make wild guesses as to what you did wrong. Answer from John D'Errico on mathworks.com
Discussions

How to plot the function f(x)=x^3 - 4x^2 +1 for x∈[0,25]
How to plot the function f(x)=x^3 - 4x^2 +1 for... Learn more about plot a graph More on mathworks.com
🌐 mathworks.com
1
0
April 14, 2015
How to format scientific notation to use "... x 10^..." instead of "...e..."
How to format scientific notation to use... Learn more about formatting, sprintf() More on mathworks.com
🌐 mathworks.com
2
0
March 30, 2021
f(x) = e^x-3x matlab code
You will see updates in your followed content feed. You may receive emails, depending on your communication preferences. ... Unable to complete the action because of changes made to the page. Reload the page to see its updated state. ... I want to write a matlab script that finds solutions of function f(x) = e^x - 3x... More on mathworks.com
🌐 mathworks.com
3
0
February 25, 2018
I need help. How do I write this function in MatLab?
you need to take a look at MATLAB syntax. Here is the equation you are trying to write: y = exp(0.5x)sin(2x) Here is what you actually wrote: y = exp(1)0.5x sin(2)x What you wrote was exponential to power of 1, times x halved, times sin of radians 2, times x. In MATLAB, to use the exponential function correctly you’d want exp(0.5.*x), same with the sin function: sin(2.*x) The command window is a great tool. Why not compare what exp(1) produces with exp(x)? Test everything to understand the syntax. Also use the documentation for any function. For example, for documentation of exp, type “help exp” or “doc exp”. More on reddit.com
🌐 r/matlab
11
1
September 14, 2021
🌐
MathWorks
mathworks.com › matlabcentral › answers › 72047-how-to-write-a-matlab-prog-for-the-exp-z-t-y-3-where-y-x-when-0-t-1-y-3-x-when-1-t-2
how to write a matlab prog. for the exp. z(t)=y^3 where y=x when 0<...
April 15, 2013 - https://www.mathworks.com/matlabcentral/answers/72047-how-to-write-a-matlab-prog-for-the-exp-z-t-y-3-where-y-x-when-0-t-1-y-3-x-when-1-t-2#comment_143328 ... Sign in to comment.
🌐
UNSW Sites
maths.unsw.edu.au › sites › default › files › MatlabSelfPaced › lesson1 › MatlabLesson1_EnterDisplay.html
MATLAB Lesson 1 - Arithmetic
The home page of UNSW's School of Mathematics & Statistics, with information on courses, research, industry connections, news, events and more.
🌐
Uccs
math.uccs.edu › sites › default › files › 2020-09 › Calc3MatlabTutorial1.pdf pdf
MATLAB Tutorial for Calculus III - Part 1 Contents 1 Introduction to MATLAB 1
If, however, everything to the right of the equals sign is numeric, then MATLAB will ... Now you can define other symbolic variables in terms of x. For example, you can define the symbolic variable ... Now you can perform operations on this symbolic expression. Try multiplying it by 2: ... You can also multiply f by another expression, say (x-3), in order to define a new polynomial, g.
🌐
Engineering LibreTexts
eng.libretexts.org › bookshelves › computer science › applied programming › a guide to matlab for me 160 (bray and montazami)
2: Basic Commands in MATLAB - Engineering LibreTexts
October 10, 2022 - In a similar manner, values taken to a power of e can be written using “exp(x)”, which would be input as “exp(4)” in MATLAB.
Find elsewhere
🌐
MathWorks
mathworks.com › matlab › programming › live scripts and functions
Insert Equations into the Live Editor - MATLAB & Simulink
Press OK to insert the equation into your live script. LaTeX expressions describe a wide range of equations. This table shows several examples of LaTeX expressions and their appearance when inserted into a live script. MATLAB supports most standard LaTeX math mode commands.
Top answer
1 of 1
1
Hi Adomas Bazinys this is John BG What you want to do is, the way you want to do it, indeed good exercise, but 1. What about *fsolve* At Mathworks the function *fsolve* was time ago developed precisely so that the people using MATLAB could save time avoiding the need for any writing of such functions, and go straight to the roots, have a look: fun = @(x) exp(x)-3*x; x0 = [1.5,0]; x = fsolve(fun,x0) x = 1.512134551657842 0.619061283355628 2. Don't start with x0=[0 0] or [1 0] because then *fsolve* only returns a single real solution 3. The requested graph fplot(fun);grid on <> . 4. And the table x_range1=0;x_range2=10;xrange_step=1; x1=[x_range1:xrange_step:x_range2]';fx1=fun(x1); T1=table(x1,fx1) T1 = 11×2 table x1 fx1 __ __________________ 0 1 1 -0.281718171540954 2 1.38905609893065 3 11.0855369231877 4 42.5981500331442 5 133.413159102577 6 385.428793492735 7 1075.63315842846 8 2956.95798704173 9 8076.08392757538 10 21996.4657948067 I assumed you ask for a MATLAB table. You can also export this table to Excel, Word or a simple .txt file, if you choose to call those the intended tables to hold the result. 5. Checking the 4 limits +- Inf +-1j*Inf syms n;limit(exp(n)-3*n, n, -inf) = Inf syms n;limit(exp(n)-3*n, n, inf) = Inf syms n;limit(exp(1j*n)-3*1j*n, n, inf) = NaN syms n;limit(exp(1j*n)-3*1j*n, n, -inf) = NaN Do you really need considering exp(1j*imx)-3*1j*imx ? If so the start point is exp(1j*imx)-3*1j*imx = cos(imx)+1j*(sin(imx)-3*imx) this would be when real(x)>>imx=imag(x) 6. the 2 real roots found with *fsolve* probably turn into a corona of complex roots that may be appreciated developing a bit further the following start point. rangelim=15;rangestep=.01; rex=[-rangelim:rangestep:rangelim]; imx=[-rangelim:rangestep:rangelim]; [RX,IX]=meshgrid(rex,imx); Z=exp(RX+1j*IX)-3*(RX+1j*IX); figure(2);hs=surf(abs(Z),RX,IX);hs.EdgeColor='none'; Adomas If interested in the complex roots, please let me know. If you find the so far supplied answer useful, would you please be so kind to consider marking my answer as Accepted Answer? To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link thanks in advance John BG
🌐
Rutgers Math
sites.math.rutgers.edu › ~falk › math373 › matlab-commands.html
Matlab Commands
* is multiplication, / is division. ... will result in the output x=2. If the variables x and y have previously been assigned values (say 2 and 3), then typing [x,y] will result in the output ans = 2 3. To label this displayed output, the Matlab commands disp and sprintf may be ...
🌐
MathWorks
mathworks.com › matlab › mathematics › elementary math › arithmetic operations
MATLAB Operators and Special Characters - MATLAB & Simulink
This page contains a comprehensive listing of all MATLAB® operators, symbols, and special characters. Some special characters can only be used in the text of a character vector or string. You can use these special characters to insert new lines or carriage returns, specify folder paths, and more.
🌐
University of Oxford
eng.ox.ac.uk › media › 8038 › matlab_notes.pdf pdf
AN INTRODUCTION TO USING MATLAB
There are hundreds of functions in MATLAB. To get started consider the standard · mathematical functions that you would expect to find on a calculator. ... The square root. ... The value rounded to the nearest integer. ... The remainder of x divided by b.
🌐
Ed
matlab.eng.ed.ac.uk › sites › matlab.eng.ed.ac.uk › files › attachments › Intro-to-MATLAB.pdf pdf
an interactive introduction to MATLAB
Additionally there are grey box environments in this document. Like the example shown (Listing 1), these contain code listings that · demonstrate actual MATLAB code.
🌐
MathWorks
mathworks.com › symbolic math toolbox › symbolic computations in matlab › symbolic variables, expressions, functions, and settings
Add Subscripts, Superscripts, and Accents to Symbolic Variables in the Live Editor - MATLAB & Simulink
Starting in R2019a, MATLAB® Live Editor displays symbolic variables with subscripts, superscripts, and accents in standard mathematical notation. This example shows how to add subscripts, superscripts, and accents to symbolic variables in the MATLAB Live Editor · To add subscripts to symbolic ...
🌐
Reddit
reddit.com › r/matlab › struggling to graph simple functions
r/matlab on Reddit: Struggling to graph simple functions
March 13, 2024 -

Hello, for my second semester of uni we are required to learn some basics of MATLAB and utilize it in calculus and other applied mathematics.

I have been trying for the past hours to understand how plot, fplot and plotting functions in general work. I need to plot these 2 functions:

y1 = (2*(x.^2)+x)./(x+3).^4;
y2 = (3*x-x.^3)./(x-5).^4;

I have been struggling hard to understand how to have both functions in the same plot, it keeps either not working at all, looking weird, or I can only get one function to show up. I have looked at the guide my school gives me, online resources and other stuff and I can not for my life figure this simple thing out. Heres my code if anyone interested, its a mix of things I found in guides that I was praying would work for me

x = linspace(-20, 20);
x(x == -3) = []; % Exclude x = -3
y1 = (2*(x.^2)+x)./(x+3).^4;
y2 = (3*x-x.^3)./(x-5).^4;
fplot(y1);
hold on
fplot(y2);
hold off
axis on;
grid on;
ylim([-10, 10]) %

🌐
Portland State University
web.cecs.pdx.edu › ~gerry › MATLAB › intro › intro.html
An Introduction to MATLAB
For example, most lines in m-files end with semicolons because only the final results of the calculations are of interest. To see how the semicolon works enter the following statements exactly as shown, ending each line with a carriage return. Do not enter the prompt character, >>. >> x = pi/3...