Hello guys i have a matrix W(418*413) i need to do a "for cycle" that goes from 2:417 and that goes from 2:412 but instead of writing down the final number i want write "end-1" but when i write end it assumes that im ending the cycle of course, how can i write the right way so it can identify that it goes from 2 line till end-1.
P.e. for nx=2:412 but instead of writing 412 i want it "end-1"
for ny=2:417 the same here.
end end

 採用された回答

Ilham Hardy
Ilham Hardy 2015 年 1 月 15 日
編集済み: Ilham Hardy 2015 年 1 月 16 日

0 投票

If i fully understand the question, below is the "cycle for loop" that you want,
for idrow = 2:size(W,1)-1
for idcol = 2:size(W,2)-1
do stuff
end
end

2 件のコメント

Jah-lahfui
Jah-lahfui 2015 年 1 月 16 日
Thanks a lot!
Jah-lahfui
Jah-lahfui 2015 年 1 月 16 日
Just could you tell me whats the point of making size(W,1) and size(W,2). The function size(W,dim) what means dim?

サインインしてコメントする。

その他の回答 (1 件)

Iain
Iain 2015 年 1 月 15 日

1 投票

for i = 2:numel(x)
do stuff
end

2 件のコメント

Jah-lahfui
Jah-lahfui 2015 年 1 月 15 日
monospaced u sure man? numel counts the number of numbers in the matrix right, but isn't there other way where i can define that i want from 1:end-1 and mathlab knows that i mean the end of W matrix?
Stephen23
Stephen23 2015 年 1 月 16 日
Iain is right: numel is the way to get the result that you want.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

質問済み:

2015 年 1 月 15 日

コメント済み:

2015 年 1 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by