Subscripted assignment dimension mismatch.

Hi
I have the vector price <1xn struct> in which we have a several information about a price of a stock. I want to have a vector in which we have all tickers name of the stock, with the following:
nome=zeros(size(price));
for t=1:size(price,2);
nome(1,t)= price(1, t).Ticker;
end
but I have the error: Subscripted assignment dimension mismatch.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 14 Mär. 2016

0 Stimmen

It is not possible to have a vector of strings in MATLAB, because strings are really vectors of characters. You will need to use cell arrays of strings:
nome{1,t} = price(1, t).Ticker;

4 Kommentare

fede
fede am 14 Mär. 2016
thanks, but now give me the following error: Cell contents assignment to a non-cell array object.
Walter Roberson
Walter Roberson am 14 Mär. 2016
Did you clear nome before you tried that? You might have a version of nome left over from before.
fede
fede am 14 Mär. 2016
Bearbeitet: Walter Roberson am 14 Mär. 2016
yeah but with the following code
for t=1:size(price,2);
nome(1,t)= price(1, t).Ticker;
end
i obtain only a cell of 1x1, indeed 1xn
fede
fede am 14 Mär. 2016
I have solved it thx

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Financial Toolbox finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by