Cell contents reference from a non-cell array object.

Hi,
I am dealing with the following error:
Cell contents reference from a
non-cell array object.
The error points me to the following line:
Error using dataset/subsrefDot
(line 80)
which corresponds to:
update(conn, tablename, columnnames, data, whereclause);
Any ideas on how to deal with the error? If needed i can provide the full code as well.

6 Comments

You will definitely need to provide your code that calls this function as that is clearly the source of the error.
%%connect to Bloomberg enviro-PRICEnment
%%create connection variable
%Set preferences with setdbprefs.
setdbprefs('DataReturnFormat', 'dataset');
setdbprefs('NullNumberRead', 'NaN');
setdbprefs('NullStringRead', 'null');
%%%%%%%%%%%%VARIABLES DE TIMER %%%%%%%%%%%%%%%%%%%%
%Tiempo de Trade 1 hora (60*60).
%t_medicion = 3600;
%Duracion de Prueba (en segundos): Trade 10 minutos (10*60).
t_medicion = 60;
%Frecuencia de Prueba 5 segundos (5*1).
t_frecuencia = 1;
t_datacommit = 0.2;
%%%%%%%%%%%%%CONEXIONES %%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BLOOMBERG
c = blp;
% ORACLEpeo
conn = database('XE','CLBCBTRADER','CLBCBTRADER_2014','oracle.jdbc.driver.OracleDriver','jdbc:oracle:thin:@localhost:1521:XE');
% EMSX %PATA ADR
b = emsx('//blp/emapisvc');
OrderStruct_Local.EMSX_ORDER_TYPE = 'LMT';
OrderStruct_Local.EMSX_BROKER = 'BCIE';
OrderStruct_Local.EMSX_TIF = 'IOC';
OrderStruct_Local.EMSX_HAND_INSTRUCTION = 'AUTO';
OrderStruct_ADR.EMSX_ORDER_TYPE = 'LMT';
OrderStruct_ADR.EMSX_BROKER = 'BCIE';
OrderStruct_ADR.EMSX_TIF = 'IOC';
OrderStruct_ADR.EMSX_HAND_INSTRUCTION = 'AUTO';
%%%%%%%%%%%%%CONEXIONES %%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LISTADO DE EQUITIES PARA ARBITRAJE
EQUITIES_curs = exec(conn, 'SELECT SECURITYID_ADR, SECURITYID_LOCAL, CONVERSION FROM ARBITRAJE_EQUITY');
EQUITIES_curs = fetch(EQUITIES_curs);
EQUITIES_numrows = rows(EQUITIES_curs);
%Assign data to output variable
l_equities = EQUITIES_curs.Data;
%INICIO DE TIMER
t = timer('TimerFcn', 'stat=false; disp(''Timer!'')',...
'StartDelay',t_medicion);
start(t);
stat=true;
% PARAMETROS PARA INSERT DE MARKET DATA EN ARBITRAJE_DATAFEED
tablename='ARBITRAJE_DATAFEED';
columnnames={'LASTPX_ADR', 'LASTPX_LOCAL', 'BID', 'ASK'};
tablename_curncy='BCI_CRNCY';
columnnames_curncy={'BID', 'ASK'};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%CICLO DE TRADE %%%%%%%%%%%%%%%%%%%%%%%%%
while(stat==true)
[C,CLP] = getdata(c, 'USDCLP DTTC Curncy', {'BID';'ASK'});
data_curncy = {C.BID, C.ASK};
whereclause_curncy = '';
update(conn, tablename_curncy, columnnames_curncy, data_curncy, whereclause_curncy);
pause(t_datacommit);
for i = 1:EQUITIES_numrows
[A,ADR] = getdata(c, l_equities.SECURITYID_ADR{i}, {'PX_LAST'});
[L,BSC] = getdata(c, l_equities.SECURITYID_LOCAL{i}, {'PX_LAST'});
data = {A.PX_LAST, L.PX_LAST, C.BID - 0.1, C.ASK + 0.1};
whereclause = strcat('WHERE SECURITYID = ''', ADR{1}, '''');
update(conn, tablename, columnnames, data, whereclause);
pause(t_datacommit);
%OBTENCION DE BUFFER
query_getbuffer = strcat('SELECT BUFFER FROM ARBITRAJE_DATAFEED WHERE SECURITYID = ''', ADR{1}, '''');
BUFFER_curs = exec(conn, query_getbuffer);
BUFFER_curs = fetch(BUFFER_curs);
BUFFER_numrows = rows(BUFFER_curs);
%Assign data to output variable
l_listbuffer = BUFFER_curs.Data;
l_buffer = l_listbuffer{1,1};
if l_buffer > 0.002 %se puede modificar
disp('ARBITRA!!!!!!');
disp(l_buffer);
%PATA LOCAL
BrokerStruct_Local.EMSX_TICKER = l_equities.SECURITYID_LOCAL{i};
BrokerStruct_Local.EMSX_BROKER = 'BCIE'; %cambiar codigo de broker
BrokerStruct_Local.EMSX_STRATEGY_NAME = 'NONE';
stratStruct_Local.EMSX_STRATEGY_FIELDS = {'EMSX_TICKER', 'EMSX_BROKER'};
stratStruct_Local.EMSX_STRATEGY_NAME = 'NONE';
stratStruct_Local.EMSX_STRATEGY_FIELD_INDICATORS = int32([0 0]);
OrderStruct_Local.EMSX_TICKER = l_equities.SECURITYID_LOCAL{i};
OrderStruct_Local.EMSX_LIMIT_PRICE = L.PX_LAST;
OrderStruct_Local.EMSX_AMOUNT = int32(100); %numero modificable
%PATA ADR
BrokerStruct_ADR.EMSX_TICKER = l_equities.SECURITYID_ADR{i};
BrokerStruct_ADR.EMSX_BROKER = 'IBKR'; %cambiar codigo de broker de IB
BrokerStruct_ADR.EMSX_STRATEGY_NAME = 'NONE';
stratStruct_ADR.EMSX_STRATEGY_FIELDS = {'EMSX_TICKER', 'EMSX_BROKER'};
stratStruct_ADR.EMSX_STRATEGY_NAME = 'NONE';
stratStruct_ADR.EMSX_STRATEGY_FIELD_INDICATORS = int32([0 0]);
OrderStruct_ADR.EMSX_TICKER = l_equities.SECURITYID_ADR{i};
OrderStruct_ADR.EMSX_LIMIT_PRICE = A.PX_LAST;
%l_ADRnumber = round(100/l_equities.CONVERSION{i});
disp(l_equities.CONVERSION{1}); % aqui esta fallando la asignacion
%disp(l_ADRnumber);
OrderStruct_ADR.EMSX_AMOUNT = int32(l_ADRnumber); %numero modificable
%rshortOrderWithStrat_Local = createOrderAndRouteWithStrat(b,OrderStruct_Local,stratStruct_Local);
%rshortOrderWithStrat_ADR = createOrderAndRouteWithStrat(b,OrderStruct_ADR,stratStruct_ADR);
end
end
disp('Market Data Insertado');
%pause(t_datacommit);
pause(t_frecuencia);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%FIN CICLO TRADE %%%%%%%%%%%%%%%%%%%%%%%%%
% CIERRE DE VARIABLES
close(EQUITIES_curs);
stop(t);
delete(t);
close(c);
close(conn);
Please give the full error code - ALL THE RED TEXT. I didn't see any cell reference in the line of code you gave so I need to see all the red text. Don't snip out just a small portion of it and paraphrase it like you did.
Error using dataset/subsrefDot
(line 80)
Cell contents reference from a
non-cell array object.
Error in dataset/subsref (line 73)
[varargout{1:nargout}] =
subsrefDot(a,s);
Error in two_leg_Arbitrage (line
120)
disp(l_equities.CONVERSION{1});
% aqui esta fallando
la asignacion
Is
l_equities.CONVERSION
a cell array?
You can just stick a breakpoint in and easily find out this kind of thing from a fairly explicit error like that.
l_equities.CONVERSION
is a cell array yes.

Sign in to comment.

 Accepted Answer

Apparently it's not a cell array at that point. Or something else is horribly wrong. This is where debug stop on errors is your best friend:
Run:
dbstop if error
This sets a condition to stop when an error is thrown so you can see everything as it is at the time of the error. Then recreate the error.
My magic eight ball guess is that l_equities.CONVERSION is empty; that it will eventually become a cell array but is not on your first iteration.

4 Comments

I tried dbstop if error but it gives me the same output. The code otherwise runs fine.
l_equities.CONVERSION looks like this.
>> l_equities.CONVERSION
ans =
3
50
30
1
However, I just tried and changed the brackets from { to ( and now at least i get a different error.
The above is not a cell array. If it was it would look like this:
ans =
[ 3]
[50]
[30]
[ 1]
And thus the {} braces are not appropriate. You could use (), it should no longer error for the same reason, but I don't know if the results are expected.

Sign in to comment.

More Answers (2)

It's not clear that l_equities.CONVERSION is even defined at that point. I searched the entire code you provided and the first time you even mentioned l_equities.CONVERSION was when you tried to display its values. But I would think you would have gotten a different error like "Reference to non-existent field 'CONVERSION'." so it probably got defined when you assigned EQUITIES_curs.Data to l_equities - "Data" must have been a structure itself with fields like "Conversion". What happens if you put these lines
l_equities
whos(l_equities)
fieldnames(l_equities)
whos(l_equities.CONVERSION)
after this call:
%Assign data to output variable
l_equities = EQUITIES_curs.Data
and also before the disp() call. Don't use semicolons at the ends of the lines.
And finally, I think "debugging by back and forth postings in a discussion forum" is tedious and takes way way too long, so what can you learn from this link.

1 Comment

thanks for all the answers. Indeed i replaced the brackets { by ( and the code works now

Sign in to comment.

Problem solved by replacing these brackets { by (.

Categories

Products

Asked:

on 15 Dec 2014

Commented:

on 16 Dec 2014

Community Treasure Hunt

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

Start Hunting!