Dimensions are always 1x1

12 ビュー (過去 30 日間)
Iris Kiebert
Iris Kiebert 2019 年 12 月 10 日
回答済み: Katharina Hofer 2019 年 12 月 10 日
No matter what I do if I type in for n=1:365 n will always have a dimension of 1x1 with the value 365.the same happens when I make a matrix. Could some help?

回答 (1 件)

Katharina Hofer
Katharina Hofer 2019 年 12 月 10 日
A for loop cycles through the columns of the array you hand it.
If you use
for n=1:365
% some code here
end
n will always be 1x1, but it will go through all values from 1 to 365, because you gave it a vector with 365 columns and it will cycle through them.
If you want n to be an array of numbers from 1 to 365, just type
n=1:365; % for a row vector
n=(1:365)'; % for a column vector

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by