Welcome Guest [Log In] [Register]
VVV REGISTER AN ACCOUNT VVV
Posted Image
^^^ CLICK THE RETARD BUTTON ^^^
It will make this annoying-as-fuck notice go away.

Username:   Password:
Add Reply
Could anyone with MATLAB/programming experience; review this code for me?
Topic Started: Tuesday 12-02-2008, 15:30 (102 Views)
Fermicelli
Member Avatar
Italian delight
I would do it myself but my license somehow expired, and I can't test it on this computer.

The assignment was to make a Matlab script that can identify whether a point P3 lies on, above or below the same line formed by points P1 and P2.

This is what I came up with:

Code:
 
function [Linedeterm] = line (x1,x2,x3,y1,y2,y3)
% P1 is determined by x1 and y1, P2 by x2 and y2
% P3 by x3 and y3
if ((y2 - y1)/(x2 - x1)) >=((y3 - y2)/(x3 - x2))
disp ('under')
elseif ((y2 - y1)/(x2 - x1)) <=((y3 - y2)/(x3 - x2))
disp ('above')
else
disp ('on')
end


I have no scripting experience whatsoever, so please don't laugh at me for this being so hard for me.

Edit: thank you, Seto. Editing my original post so I won't accidentally copy the wrong stuff tomorrow.
Offline Profile Quote Post Goto Top
 
Wakapanda Of Doom
Member Avatar
ONE OF THE ORIGINAL FUCKS
<_<

I feel like an idiot trying to decypher whatever that quote was ...
Offline Profile Quote Post Goto Top
 
Steve Jobs
Member Avatar
Ceo, Founder, Deity of Apple, Inc
Triforce Wisdom
Feb 12 2008, 10:30 AM
I would do it myself but my license somehow expired, and I can't test it on this computer.

The assignment was to make a Matlab script that can identify whether a point P3 lies on, above or below the same line formed by points P1 and P2.

This is what I came up with:

Code:
 
function [Linedeterm] = line (x1,x2,x3,y1,y2,y3)
% P1 is determined by x1 and y1, P2 by x2 and y2
% P3 by x3 and y3
if ((y2 - y1)/(x2 - x1)) >=((y3 - y2)/(x2 - x3))
disp ('under')
elseif ((y2 - y1)/(x2 - x1)) <=((y3 - y2)/(x2 - x3))
disp ('above')
else
disp ('on')
end


I have no scripting experience whatsoever, so please don't laugh at me for this being so hard for me.

First off, shouldnt it be ((y3 - y2)/(x3- x2))? It looks like you are testing to see if the point is on the line based off of whether the slope between p1 and p2 equals the slope between p2 and p3, right? I see nothing wrong with that concept or how you did it, minus the first thing I said.

I only have programmed in MathLab once, so I am not sure if you have syntax errors, but the general concept you have is good.
Offline Profile Quote Post Goto Top
 
MLWW
Member Avatar
Dutch Bastard
Wakapanda Of Doom
Feb 12 2008, 05:17 PM
<_<

I feel like an idiot trying to decypher whatever that quote was ...

:yeah:
Offline Profile Quote Post Goto Top
 
ZessF
No Avatar
Boobs
Code:
 
CLS
PRINT "I ONLY KNOW A LITTLE BASIC LOL"
Offline Profile Quote Post Goto Top
 
Fermicelli
Member Avatar
Italian delight
Quote:
 
First off, shouldnt it be ((y3 - y2)/(x3- x2))?


Whoops.

Thank you, Seto.
Offline Profile Quote Post Goto Top
 
Legoroll
Member Avatar
Dr. Pepper
lol

Do somthing in Psuedo-Code (and a little VBasic) THEN ask for my help...everything else is beyond me.
Offline Profile Quote Post Goto Top
 
Speed
Member Avatar
Bounty Hunter
Ugh, I hate MATLAB. I'm glad that class is over.
@_@
Offline Profile Quote Post Goto Top
 
RikusSexSlave
Member Avatar
Fuckin Hadoken
My roommate is studying MATLAB. I'd call him over to look at it, but I don't know what he'd think of me if he saw my avatar.
Offline Profile Quote Post Goto Top
 
Fermicelli
Member Avatar
Italian delight
RikusSexSlave
Feb 12 2008, 11:44 PM
My roommate is studying MATLAB. I'd call him over to look at it, but I don't know what he'd think of me if he saw my avatar.

What if it arouses him? :saturn:
Offline Profile Quote Post Goto Top
 
RikusSexSlave
Member Avatar
Fuckin Hadoken
Triforce Wisdom
Feb 12 2008, 05:54 PM
RikusSexSlave
Feb 12 2008, 11:44 PM
My roommate is studying MATLAB. I'd call him over to look at it, but I don't know what he'd think of me if he saw my avatar.

What if it arouses him? :saturn:

His granny fetish is quite the opposite of 3 year-old powerpuff girls.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
ZetaBoards - Free Forum Hosting
ZetaBoards gives you all the tools to create a successful discussion community.
« Previous Topic · Wackapedia · Next Topic »
Add Reply

The Gamer Gateway