problem in strcat
이전 댓글 표시
Hello,
%I use the below sample of huge txt file:
ETE 04/01/2010 10145959 18.31 500 Big Cap
ETE 04/01/2010 10150000 18.01 70 Big Cap
ETE 04/01/2010 10170000 18.54 430 Big Cap
ABC 04/01/2010 10190000 18.34 200 Big Cap
%Then, I use the below codes to create a new binary column 'TRADE' with values 'Buy' or 'Sale'.
% Read stock data from file fid = fopen('stocks.txt');
data = textscan(fid,'%s%s%f%f%f%[^\n]','delimiter',' ','headerlines',1);
% Read as text (for later writing)
frewind(fid);
txt = textscan(fid,'%s','delimiter','\n');
fclose(fid);
% Get prices from imported data
Price = data{4};
% Determine which stocks to buy
buy = [true;diff(Price)>=0];
idx = find(~diff(Price));
buy(idx+1) = buy(idx);
% Make string of trade decision
buysell = cellstr(repmat(' Sell',size(Price)));
buysell(buy) = {' Buy'};
% Open file for writing fid = fopen('stocks2.txt','wt');
% Make output string by appending trade decision outstr = strcat(txt{1},[' Trade';buysell]);
% Write out fprintf(fid,'%s\n',outstr{:}); fclose(fid);
% When I apply these codes to the sample file (53 MB) it works fine, but when I apply this to the original file (540 MB) there is the below error message:
outstr = strcat(txt{1},[' Trade';buysell]);
??? Error using ==> cell.strcat at 50
All the inputs must be the same size or scalars.
Could anyone help on what the above pertains to, and how can I solve this problem?
Many thanks in advance,
Panos
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!