Turn on thread page Beta
    • Thread Starter
    Offline

    0
    ReputationRep:
    hi, im having some troubles with matlab.

    lets say there's two lines that needed to be plotted.

    one of the lines we will call the maximum, which would be

    x = [1 2 3 4 5]
    y = [1 2 3 4 5]
    , the other line we will call the minimum, which would be

    x = [1 2 3 4 5]
    y = [1 4 6 8 10]

    I need to find a third line which is the average, how do i program matlab to do this, and put all the 3 lines on the same graph?

    rep goes to the first most helpful answer!!
    Offline

    0
    ReputationRep:
    (Original post by Jukukiwaiyi)
    hi, im having some troubles with matlab.

    lets say there's two lines that needed to be plotted.

    one of the lines we will call the maximum, which would be

    x = [1 2 3 4 5]
    y = [1 2 3 4 5]
    , the other line we will call the minimum, which would be

    x = [1 2 3 4 5]
    y = [1 4 6 8 10]

    I need to find a third line which is the average, how do i program matlab to do this, and put all the 3 lines on the same graph?

    rep goes to the first most helpful answer!!
    I THINK I see what you're trying to do so I'll give it a go. Firstly, you're going to want to give these variables different names really so as to not confuse matlab. Perhaps something like

    x=[1 2 3 4 5]
    ymax=[1 2 3 4 5]
    ymin = [1 4 6 8 10]

    and by average, I suppose you just mean the average of the two y vectors? In which case you could do something like
    yavg=(ymin+ymax)./2 which will give you the average of ymin and ymax. To plot them, just use plot(x,ymax); hold on; plot(x,ymin); hold on; plot(x,yavg). And this will give you all three on the same graph. Is this what you wanted?
    Offline

    0
    ReputationRep:
    what you said looks right, necro.
    Offline

    14
    ReputationRep:
    Urgh, ive got to learn this crap for an exam next week
    Offline

    0
    ReputationRep:
    (Original post by Nick Longjohnson)
    Urgh, ive got to learn this crap for an exam next week
    if you're doing engineering, i doubt it would be this difficult!
    • Thread Starter
    Offline

    0
    ReputationRep:
    okeis thanks guys
    Offline

    0
    ReputationRep:
    (Original post by Nick Longjohnson)
    Urgh, ive got to learn this crap for an exam next week
    i have to say your sig and profile are awesome

    and i HATE matlab, it is BS...even if it does make my life easier lol
    • Thread Starter
    Offline

    0
    ReputationRep:
    (Original post by Necro Defain)
    I THINK I see what you're trying to do so I'll give it a go. Firstly, you're going to want to give these variables different names really so as to not confuse matlab. Perhaps something like

    x=[1 2 3 4 5]
    ymax=[1 2 3 4 5]
    ymin = [1 4 6 8 10]

    and by average, I suppose you just mean the average of the two y vectors? In which case you could do something like
    yavg=(ymin+ymax)./2 which will give you the average of ymin and ymax. To plot them, just use plot(x,ymax); hold on; plot(x,ymin); hold on; plot(x,yavg). And this will give you all three on the same graph. Is this what you wanted?
    soww wont lemme give you rep, i already given you rep 2 days a go
    Offline

    14
    ReputationRep:
    (Original post by dichr0ic)
    if you're doing engineering, i doubt it would be this difficult!
    Its a heck of a lot worse.

    "write a program to calculate prime numbers until the user stops the program/up to an upper limit set by the user" (((

    wait theres more "Apply a symmetric low-pass filter to create a filtered signal (z) from the mean value of itself and its neighbours..." This is on an array x of integers 0-300, and an array y (300 random numbers of 0-1). God im screwed
 
 
 
Poll
Cats or dogs?
Useful resources

Make your revision easier

Maths

Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

Equations

How to use LaTex

Writing equations the easy way

Student revising

Study habits of A* students

Top tips from students who have already aced their exams

Study Planner

Create your own Study Planner

Never miss a deadline again

Polling station sign

Thinking about a maths degree?

Chat with other maths applicants

Can you help? Study help unanswered threads

Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.