Question

Write a program that evaluates the function f(x) = tan’x + x - 2 between -27 and 27 in steps of 1/10 and plots the results. C

i need Matlab code asap

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. Solution

% myFunction.m

% defining myFunction for question 1
function f = myFunction(x)
  
f = tan(x).^2 + x -2;
  
end

% driver.m

% create funtion handler for myFunction
fun = @myFunction;

% initialize the given range with pi/10 step
r = -2*pi: pi/10 : 2*pi;

% use feval to evaluate fun in range r
result = feval(fun, r);

% Now plot the result
plot(r, result);

% SCREENSHOTS

% myFunction.m

1 $defining myFunction for question 1 function f = myFunction(x) N 3 f = tan(x).^2 + x -2; 5 6 - end

% driver.m

1 create funtion handler for myFunction fun = @myFunction; 2 - 3 4 initialize the given range with pi/10 step r = -2*pi: pi/1

%OUTPUT (plot of results)

331032 2.5 2 1.5 1 0.5 0 -0.5 -8 -6 -4 -2 0 2 4 6 8

Add a comment
Know the answer?
Add Answer to:
i need Matlab code asap Write a program that evaluates the function f(x) = tan’x +...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT