how can i solve such two problems in single script file and run them?
2 views (last 30 days)
Show older comments
- Write a user-defined function for the following math function:
y(x)=(-0.3x^4+6x^2 ) e^(-0.2x)
The input for the function is x and the output for the function is y.
- Write a user-defined function for the following math function:
r(θ)=5 cos(2 sin(θ) )
The input to the function is θ in radians and the output is r.
0 Comments
Answers (3)
Ollie A
on 31 Jan 2019
There are two ways you could construct your function, as a symbolic function using syms, or as an expression that operates on a predefined input. Using the symbolic function method, your first function is constructed as so:
syms y(x)
y(x) = (-0.3*x^4 + 6*x^2)*exp(-0.2*x); % Your function
double(f(userinput))
Or the simpler method:
x = linspace(0,100,1000); % Inputs
y = (-0.3*x.^4 + 6*x.^2).*exp(-0.2*x); % Your function
Now that you've seen these two examples you should be able to construct your second function.
Note: using syms may require the symbolic functions toolbox.
0 Comments
Angela Borer
on 31 Jan 2022
You can include the code in a loop. For example, you could create a variable. Then, you would use a loop to run through each of your two problems. Inside for loop, you should visit https://www.aussiessay.com/ for further info and call the script with the appropriate parameters. If you want, you can also add an else statement that runs if the problem has not been solved by any of the scripts inside of the loop.
0 Comments
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!