How to test a math function with different values of x?
Show older comments
Hi all,
I am trying to take two math functions, (y and z) test them with 3 different values of x and print the results of each value in the two equations. I have made it so that I can test and print on of the values but I have not been able to modify my script to get it to test all 3 values and print the results. What I currently have follows:
%Clear command window and variables
clear
clc
%Naming Variables to make the equations cleaner
x = 1.2;
A = 3 * sin(x^3);
B = 4 * x + 3;
C = 2 * (x + 3);
D = exp(x) + 2;
E = 2 + 3 * x^3;
%Equations y and z, respectively
y = A./B;
z = C + (D./E);
%Print out the values of y and z
fprintf('For x=1.20 y is %0.06f, z is %0.06f', y, z)
This returns the following in the command window:
For x=1.20 y is 0.379873, z is 9.140551>>
Any help would be appreciated!
Accepted Answer
More Answers (0)
Categories
Find more on Whos 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!