フィルターのクリア

How to combine two outputs of a into a single vector.

5 ビュー (過去 30 日間)
Pallav Patel
Pallav Patel 2020 年 3 月 11 日
コメント済み: Star Strider 2020 年 3 月 11 日
L = randi([2,5]);
lo = [1,5,10]
hi = [3,8,9]
for k = 1:length(hi)
if hi(k(1:end))>lo(k(1:end))
a=[lo(k):hi(k)]
end
end

採用された回答

Star Strider
Star Strider 2020 年 3 月 11 日
I am not certain what result you want.
Try this:
L = randi([2,5]);
lo = [1,5,10];
hi = [3,8,9];
for k = 1:length(hi)
if hi(k(1:end))>lo(k(1:end))
a{k}=[lo(k):hi(k)];
end
end
  4 件のコメント
Pallav Patel
Pallav Patel 2020 年 3 月 11 日
Thank you Strider. I just started learning arrays and was trying to add them using a counter like loops withput arrays. This makes much sense. Both of them work but my book does not cover the braces function and I was unable to comprehend how it works but the second one has made itt easier to understand both methods.
Star Strider
Star Strider 2020 年 3 月 11 日
As always, my pleasure!
The first one creates ‘a’ as a cell array, then converts it to a numeric array using the square brackets. See the information in the See Also section of that documentation page to learn more about them.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by