clc,clear
% tic .... toc 用来统计运行时间
%tic
%% 其他加载数据的命令: load "data.dat"
%字符转换:
% % % % % % 1、cell2mat:将cell转换为mat的char型
% % % % % % 2、str2num:将mat从char转换为double型
% % % % % % 3、cellstr:将char转cell
% % % % % % 4、num2str:将double转char
% % % % % % 5、num2cell:将double直接转cell
[num,txt,raw]=xlsread('C:\Users\leo\Desktop\DesmondOkello\Data\tbl_stock(new).xls'); %num接收读取的数值数据, txt为cell类型,读取字符,raw为cell类型,能同时读取字符或者数字
matrix_col=size(txt,2)
matrix_row=size(txt,1)
result=[];
%Westinghouse Clip-On Gooseneck Lamps:
%Tennsco 6- and 18-Compartment Lockers
%Flat Face Poster Frame
%Acme Value Line Scissors
temp=1;
itemname='Acme Value Line Scissors';%'Westinghouse Clip-On Gooseneck Lamps';
for n=2:matrix_row
%if char(b())==itemname
name=char(txt(n,10));
%disp(name)
if length(name)==length(itemname) % 必须先判断长度,因为matlab中 name==itemname 要求两者字符串长度必须一致,否则不能比较会报错
if name==itemname
n=n-1;
%%%%%%%%% 5num(n,2):quantity num(n,4):buying_price num(n,5):transport_fee
result(temp)=num(n,5); % Others: num(n,1):id txt(n,3):stock_date num(n,6):status num(n,7):current_level txt(n,8):product_id txt(n,9):sub_category txt(n,10):product_name
% disp(num(n,2));
temp=temp+1;
end
end
end
% disp(itemname)
sprintf('%s数量是:',itemname)
result
% toc