×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

plot 2 graphic but continous

plot 2 graphic but continous

plot 2 graphic but continous

(OP)
i need someone's help n i have a question

How to plot two or more functions but they are cointinous.
the functions maybe like:

y1=2*x     for 0<x<2
y2=4       for 2<x<4
y3=2       for x>4

how to plot them in a cartesian coordinate, together.
following illustration is what i want to plot!!

           _____
          /
         /      _______
        /
       /

how i can do that with standar ploting matlab command...?
(x and y are symbolic expression)
please help me! thank's a lot.

RE: plot 2 graphic but continous

try something like this (it is very straight forward),

x=0:.1:10;
plot(x,yourfunctionname(x));

function [ y ] = yfunc( x )
%YFUNC Summary of this function goes here
%  Detailed explanation goes here
for i=1:size(x,1)
if x(i,1) > 0 & x(i,1) <= 2
  y(i,1)=2*x(i,1);
elseif x(i,1)>2 & x(i,1)<4
  y(i,1)=4;
elseif x(i,1)>4
  y(i,1)=2;
else
  y(i,1)=NaN;
end
end

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources