Question

Plot f(x) = x^3 - y using MATLAB. Include zero crossings in the plot.

Plot f(x) = x^3 - y using MATLAB. Include zero crossings in the plot.

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

What is a zero crossing?
They are such points at which a function crosses the horizontal axis as its value passes through zero and changes sign.

Given f(x) = x3 - y .
f(x) is nothing but y . Therefore f(x) = x3 - y becomes y = x3 - y   => y = 0.5 * x3

x = [-10:0.01:10];        % The range fom where to where to plot
y = 0.5 * x.^3;             % function
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0);        % creating a function which returns zero-crossing indices of argument vector v
zx = zci(y);                % approximating the zero-crossing indices and storing it in zx
figure(1)
plot(x,y,'-r')                % plotting x vs y in red colour
hold on                     % holding on to the current plot to add graphing command to exisiting plot
plot(x(zx),y(zx),'*')     % adding another graphing command to the plot i.e. the zero-crossing points and mark such points with '*'
hold off                     % hold off since all changes are done
grid                          % show grid in graph
legend('function','zero crossing')       % setting legend for the plot


HERE IS THE PLOT FOR THE ABOVE QUESTION :

500 400 300 200 100 function zero crossing 0 -100 200 300 400 -500 -10 -8 -6 42 2 4 6 8 0 0

Add a comment
Know the answer?
Add Answer to:
Plot f(x) = x^3 - y using MATLAB. Include zero crossings in the plot.
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