フィルターのクリア

need to skip iterations in a for loop

3 ビュー (過去 30 日間)
John Hendricks
John Hendricks 2022 年 4 月 25 日
コメント済み: John Hendricks 2022 年 4 月 25 日
I'm trying to set values in a row of a large 2D matrix to 1, but i need to skip every two entries, so have my last row look something like 1001001001 instead of my current L(bottomrow,:)=1. I was thinking about using a for loop but i'm not so sure how to set that up, I tried
L=zeros(1024,1024);
for n=(2:1022:3)
L(1024,n)=1
end
using n from 2 to 1022 because i'm using dummy arrays for my code.

採用された回答

Chunru
Chunru 2022 年 4 月 25 日
L=zeros(1024,1024);
% for n=(2:1022:3)
% L(1024,n)=1
% end
% Set the last row (first end), column 2 to last column with a step 3 to be
% 1 (you can adjust this for your need)
L(end, 2:3:end) = 1;
L(end, :)
ans = 1×1024
0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0
  1 件のコメント
John Hendricks
John Hendricks 2022 年 4 月 25 日
Thanks for helping a matlab newbie such as myself :)

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by