문제

This is the current code I'm attempting to use in order to loop through a "list" of tickers to load the corresponding file. However, Matlab doesn't seem to like to accept separate strings. I'm not quite sure how Matlab functions yet. However, it is clear that it does not handle text as easily as Python.

    Stocks = {'JPM','KO','GOOG','PG'};
    for Stock = Stocks;
        stockData.(Stock) = load(Stock '.csv');
    end
도움이 되었습니까?

해결책

Your syntax is invalid. I don't know what stockData is, and what you want to assign to it, but here's a loop that iterates through the cell array Stocks and loads each file in turn:

Stocks = {'JPM','KO','GOOG','PG'};
for i = 1:length(Stocks);
    load([Stocks{i}, '.csv'])
end

You can keep going from here.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top