Matrix Dimensions must agree
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
[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
0 commentaires
Réponse acceptée
Walter Roberson
le 26 Mai 2011
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur String Parsing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!