HOW TO WRITE THE FOLLOWING FUNCTION IN A MATLAB PROGRAM ? ALSO TELL THE WAY TO PLOT F(X)

Antworten (1)

x = linspace(1e-6,2-1e-6,100);
f1 = x(x>0&x<1);
f2 = x(x>1&x<2)/2+5;
plot(x,[f1,f2])

2 Kommentare

Out of interest, what happens using this code if x is exactly 1?
I'll crash since x and [f1,f2] will be of different sizes. That's a cheap and easy solution to plot the function, not meant to represent all the occurrences. Can be modified as:
plot(x(x>0&x<2&x~=1),[f1,f2])

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Numerical Integration and Differential Equations finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 16 Jul. 2014

Kommentiert:

am 16 Jul. 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by