How can I show the ranges in the graph of a function?

I must shou (-0,8; 0,8)

2 comentarios

Do you mean you need to draw vertical lines at -0.8 and +0.8 ?
HUST Student
HUST Student el 29 de Oct. de 2015
Editada: HUST Student el 29 de Oct. de 2015
I wanted to point out this interval (-0.8, 0.8) in the graph of the function changing the line texture, for example to dashed - - - -
if it is not possible point out range in this way. X can be placed at the beginning and end of the interval on the graph of the function

Iniciar sesión para comentar.

Respuestas (1)

To change a line texture part way through a line, you need to draw a different line for each part that has a different texture. For example,
idx1 = find(x < -0.8);
idx2 = find(-0.8 <= x & x <= 0.8);
idx3 = find(0.8 < x);
idx1t = [idx1(:); idx2(1)];
idx2t = idx2;
idx3t = [idx2(:); idx3(1)];
plot( x([idx1t), y(idxt), '-');
hold on
plot(x(idx2t), y(idx2t), '--');
plot(x(idx3t), y(idx3t), '-');
The extra work with the *t variables is to allow the segments to join up.

3 comentarios

HUST Student
HUST Student el 29 de Oct. de 2015
Editada: HUST Student el 29 de Oct. de 2015
x=-2.4:0.1:2.4;
>> y=1/6*x.^6-5/4*x.^4+2*x.^2;
>> idx1 = find(x < -0.8);
>> idx2 = find(-0.8 <= x & x <= 0.8);
>> idx3 = find(0.8 < x);
>> idx1t = [idx1(:); idx2(1)];
>> idx2t = idx2;
>> idx3t = [idx2(:); idx3(1)];
>> plot( x([idx1t), y(idxt), '-');
plot( x([idx1t), y(idxt), '-');
|
Error: Unbalanced or unexpected parenthesis or bracket.
What I did wrong???
plot( x(idx1t), y(idx1t), '-');
I correct it! I will try one more time
Thank you!!!!! It worked!!!!

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 29 de Oct. de 2015

Comentada:

el 29 de Oct. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by