フィルターのクリア

Matrix Dimensions must agree

3 ビュー (過去 30 日間)
luke
luke 2011 年 5 月 26 日
[EDIT: 20110526 14:35 CDT - reformat - WDR]
I am running the following script and I get the error message below.
=== ERROR =====
??? Error using ==> eq
Matrix dimensions must agree
=== ERROR =====
If I look at the output from the recCnt it has count of the last record in the file, so I am really stumped. It seems to work until it gets to the end of the file and then dies.
Any Suggestions?
file_option=fopen('C:\Users\Sample with Dividends.csv');
A=textscan(file_option,['%s %s %s %f %s %f %f %f %f %f %f %f %f %f %f %f %s %s %s %f %f %f %f %f %f %f %s %f %f %s %f %s'], 'delimiter',',','HeaderLines', 1);
%%%Option input%%%%
Date1=datenum(A{:,1});
expiration1=datenum(A{:,3});
strike1=A{:,4};
callORput=A{:,5};
%option_symbol=A{:,6};
bid1=A{:,6};
ask1=A{:,7};
mean_price=A{:,8};
openInt = A{:,9};
volume = A{:,10};
IV1=A{:,11};
delta1=A{:,12};
Gamma1=A{:,13};
theta1=A{:,14};
vega1=A{:,15};
rho1=A{:,16};
%
symbol = A{:,17};
name = A{:,18};
stockOpen = A{:,21};
stockHigh = A{:,22};
stockLow = A{:,23};
stockClose = A{:,24};
priceClose = A{:,25};
divFreq = A{:,26};
divCalcDate = A{:,27};
divID = A{:,28};
lastDivAmt =A{:,29};
lastDivDate = A{:,30};
prev_Symbol = symbol{1};
recCnt = 0;
length(Date1)
for i = 1:length(Date1)
if symbol{i} == prev_Symbol
recCnt = recCnt + 1;
%display ( recCnt)
else
display (recCnt)
prev_Symbol = symbol{i}
recCnt = recCnt + 1;
end
end

採用された回答

Walter Roberson
Walter Roberson 2011 年 5 月 26 日
You are attempting to compare two character arrays using "==". That works as long as the character arrays are exactly the same length, but fails if they are different lengths. You should be using strcmp() instead of "==".

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by