Trying to assign into multiple variables using a for loop

5 ビュー (過去 30 日間)
Or Shem Tov
Or Shem Tov 2020 年 2 月 25 日
コメント済み: Or Shem Tov 2020 年 2 月 26 日
Hi there,
I have a loop here that generates a table, I want to save the table I get before going in and getting another table and save that one too until the end of the loop
In the end I need to have something like x[1]=temp_news[1], x[2]=temp_news[2] and so on and so on...
Would really appreciate your help.
Thanks !
for i = 1:s(1,1)
temp_news = news(c,'Symbol',symbol(i),'Category',"Analyst Ratings")
%% storehere[1:s(1,1] = temp_news - trying to create a variable here that will save the result and then continue the loop and save the rest in other variables
end

回答 (1 件)

Stephen23
Stephen23 2020 年 2 月 25 日
編集済み: Stephen23 2020 年 2 月 25 日
Use a cell array:
N = s(1,1);
C = cell(1,N);
for k = 1:N
C{k} = news(c,'Symbol',symbol(k),'Category',"Analyst Ratings");
end

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by