Creating a vector of stock symbols
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Zack Bayhan
el 9 de Dic. de 2014
Comentada: Zack Bayhan
el 9 de Dic. de 2014
Hi everyone I'm attempting to create a vector of stock symbols which I will run through a function to retrieve information about the symbol. When I go to create a vector which I plan to run through the function
symbol=['NLY', 'CSCO', 'RAI'];
it returnes that it's equal to
NLYCSCORAI,
is there a way to make to make it work where the entered symbol in the vector can be used this way? I need it to return 'NLY' to have the function work properly, otherwise there is a breakdown in the program. Also I've found when I do a loop it strips the number of letters specified by the loop instead of treating whats inside of the '...' as a unit.
here is the script if you need the function I can get that as well
symbol=['NLY', 'CSCO', 'RAI'];
[hist_date, hist_high, hist_low, hist_open, hist_close, hist_vol] = get_hist_google_stock_data('symbol');
% Plot Daily Hi vs Low
figure
plot([hist_low,hist_high,log(hist_vol)]);
title('Stock');
xlabel('Days Back');
ylabel('Price');
legend('Blue=Daily High','Green=Daily Low','Red=Log(Volume)')
0 comentarios
Respuesta aceptada
Guillaume
el 9 de Dic. de 2014
[] on strings (char array) concatenates the strings. To hold several strings of different lengths you have to use a cell array:
symbols = {'NLY', 'CSCO', 'RAI'};
to access your symbols you use the {} operator to index into the cell array instead of the matrix ():
for symbidx = 1:numel(symbols)
symbol = symbols{symbidx}
[hist_date, hist_high, hist_low, hist_open, hist_close, hist_vol] = get_hist_google_stock_data(symbol);
%...
end
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!