Path: news.mathworks.com!not-for-mail
From: "Jacob " <jblank@tulane.edu.removethis>
Newsgroups: comp.soft-sys.matlab
Subject: For/If statement monitoring position of item
Date: Thu, 8 Mar 2012 02:06:12 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 62
Message-ID: <jj946k$954$1@newscl01ah.mathworks.com>
Reply-To: "Jacob " <jblank@tulane.edu.removethis>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1331172372 9380 172.30.248.45 (8 Mar 2012 02:06:12 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 8 Mar 2012 02:06:12 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3367550
Xref: news.mathworks.com comp.soft-sys.matlab:760284

I'm trying to create a demo of a store monitoring system which takes location data, maps it over a store blueprint with defined exit and payment areas, and displays a warning if a product enters the exit area without first entering the payment area.

with the code i've written so far, everything works fine except for changing the payment status of a product (variable P#pay) from unpaid (0) to paid (1).  The code i wrote changes the payment status to 1 regardless of location, and I'm not sure what i did wrong. [note: i've yet to code the pay/nopay warning as i'm stuck here....] below is the code, and thanks for your help!

% Blank, Jacob
clear all
close all
clc
%define store dimensions blueprint
    hold on
    rectangle('position',[0,0,120,110])
%define shelving units
    rectangle('position',[15,20,10,75],'facecolor','y')
    rectangle('position',[35,20,10,75],'facecolor','y')
    rectangle('position',[55,20,10,75],'facecolor','y')
    rectangle('position',[75,10,10,30],'facecolor','y')
    rectangle('position',[90,10,10,30],'facecolor','y')
    rectangle('position',[105,10,10,30],'facecolor','y')
%define freezer space
    rectangle('position',[75,75,40,15],'facecolor','c')
    rectangle('position',[75,50,40,15],'facecolor','c')
%define payment portal
    rectangle('position',[15,0,20,10],'facecolor','g')
    text(21,5,'PAY')
    payYlimMax=10;
    payYlimMin=0;
    payXlimMax=35;
    payXlimMin=15;
%define exit
    rectangle('position',[0,0,15,10],'facecolor','r')
    text(2,5,'EXT')
    extYlimMax=10;
    extYlimMin=0;
    extXlimMax=15;
    extXlimMin=0;
%product 1 location data
    P1 = xlsread('location_data','Product 1');
    n=size(P1,1);
    P1X=P1(2:n,1);
    P1Y=P1(2:n,2);
    plot(P1X,P1Y,'ko');
%product 1 payment status  
    P1pay=0;
    for i=1:n-1
        if payXlimMin < P1X(i) < payXlimMax && payYlimMin < P1Y(i) < payYlimMax
            P1pay = 1;
        end
    end   
%product 2 location data
    P2 = xlsread('location_data','Product 2');
    n2=size(P2,1);
    P2X=P2(2:n2,1);
    P2Y=P2(2:n2,2);
    plot(P2X,P2Y,'ko');
%product 2 payment status  
    P2pay=0;
    for i2=1:n2-1
        if payXlimMin < P2X(i2) < payXlimMax && payYlimMin < P2Y(i2) < payYlimMax
            P2pay = 1
        end
    end      
    hold off