|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
以下是我用matlab调用sql2000画图的程序,可以顺利画图。
但是现在要用matlab调用sql2005,一调用好像识别不了行列似的,错误直接就是:
??? Attempted to access dis(:,3); index out of bounds because numel(dis)=1.
Error in ==> petridata at 28
dis_order=dis(:,3)';
请高手帮忙指导!
clear all
close all
clc
timeout=logintimeout(5);
% Connect to a database.
conn=database('PetriSCM','sa','123');
setdbprefs('DataReturnFormat','numeric');
% Check the database status.
totaltime=2000;
cursor_dis=exec(conn,'select step,inventory,orders,inventory1,inventory2,Cost from distributor');%执行SQL语句和打开油标
cursor_dis=fetch(cursor_dis,totaltime);%导入数据到MATLAB单元数组
dis=cursor_dis.Data;
dis_order=dis(:,3)';
dis_inventory=dis(:,2)';
dis_Cost=dis(:,6)';
cursor_man=exec(conn,'select step,inventory,orders,inventory1,inventory2,Cost from manufactor');
cursor_man=fetch(cursor_man,totaltime);
man=cursor_man.Data;
man_order=man(:,3)';
man_inventory=man(:,2)';
man_Cost=man(:,6)';
cursor_sup=exec(conn,'select step,inventory,orders,inventory1,inventory2,Cost from supplier');
cursor_sup=fetch(cursor_sup,totaltime);
sup=cursor_sup.Data;
sup_order=sup(:,3)';
sup_inventory=sup(:,2)';
sup_Cost=sup(:,6)';
sCost=sup_Cost(2000)/2000
dCost=dis_Cost(2000)/2000
mCost=man_Cost(2000)/2000
Cost=sCost+dCost+mCost
n=1:totaltime;
figure(1);
plot(n,dis_inventory,'--r',n,man_inventory,'-.b',n,sup_inventory,'-m');
legend('distributor','manufacturer','supplier');
title('Inventory-Time');
xlabel('Time(weeks)');
ylabel('Inventory');
[ 本帖最后由 zebtra_stripe 于 2010-1-22 12:21 编辑 ] |
|