Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
ticker

Subject: ticker

From: Mariagiovanna

Date: 13 May, 2013 16:41:11

Message: 1 of 2

I'm trying to get some data from yahoo in order to create a portfolio.

That's what I written:

conn=yahoo;
startDate='Jan 01 08';
endDate='Dec 31 11';
tickers={'ENI.MI','SPM.MI','TEN.MI','BZU.MI','FNC.MI','PRY.MI','FI.MI','STS.MI','ATL.MI','F.MI','PC.MI','CPR.MI','PLT.MI','LUX.MI','SFER.MI','TOD.MI','DIA.MI','MS.MI','AGL.MI','LTO.MI','TIT.MI','A2A.MI','ENEL.MI','EGPW.MI','TNR.MI','SGR.MI','BMPS.MI','BPE.MI','PMI.MI','BP.MI','ISP.MI','MB.MI','UBI.MI','UCG.MI','G.MI','MED.MI','AZM.MI','EXO.MI','STM.MI'};
for ii=1:length(tickers)
    Price.(tickers{ii})=fetch(conn,tickers{ii},'Adj Close',startDate,endDate,'m');
    temp=Price.(tickers{ii});
    ClosePrice(:,ii)=flipud(temp(:,2));
end

tickers are the yahoo code for my stocks.
I don't know why Matlab sais: ?Invalid field Name for ENI.MI.
ANYONE CAN SAY ME WHY?

THANK YOU

Subject: ticker

From: Steven_Lord

Date: 13 May, 2013 16:59:29

Message: 2 of 2



"Mariagiovanna " <m.maddaloni2@libero.it> wrote in message
news:kmr537$ku7$1@newscl01ah.mathworks.com...
> I'm trying to get some data from yahoo in order to create a portfolio.
>
> That's what I written:
>
> conn=yahoo;
> startDate='Jan 01 08';
> endDate='Dec 31 11';
> tickers={'ENI.MI','SPM.MI','TEN.MI','BZU.MI','FNC.MI','PRY.MI','FI.MI','STS.MI','ATL.MI','F.MI','PC.MI','CPR.MI','PLT.MI','LUX.MI','SFER.MI','TOD.MI','DIA.MI','MS.MI','AGL.MI','LTO.MI','TIT.MI','A2A.MI','ENEL.MI','EGPW.MI','TNR.MI','SGR.MI','BMPS.MI','BPE.MI','PMI.MI','BP.MI','ISP.MI','MB.MI','UBI.MI','UCG.MI','G.MI','MED.MI','AZM.MI','EXO.MI','STM.MI'};
> for ii=1:length(tickers)
> Price.(tickers{ii})=fetch(conn,tickers{ii},'Adj
> Close',startDate,endDate,'m');
> temp=Price.(tickers{ii});
> ClosePrice(:,ii)=flipud(temp(:,2));
> end
>
> tickers are the yahoo code for my stocks.
> I don't know why Matlab sais: ?Invalid field Name for ENI.MI.
> ANYONE CAN SAY ME WHY?

The string ENI.MI is not a valid field name for a structure in MATLAB. Field
names must satisfy these three requirements:

1) The name must start with a letter.
2) The name must contain only letters, numbers, and the underscore
character.
3) The name must be no longer than NAMELENGHTMAX.

The name ENI.MI violates the second requirement due to the period.

You can use GENVARNAME to convert the strings in the tickers cell array into
valid struct field names. See example 3 on the documentation page:

http://www.mathworks.com/help/matlab/ref/genvarname.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us