I have multiple files. I need to combine info in the files.

1 回表示 (過去 30 日間)
Sunshine
Sunshine 2020 年 10 月 25 日
コメント済み: Rik 2020 年 10 月 25 日
I have multiple files of the same length that represent a and b. For each value in a, I need to create a table such that I get a1b1, a1b2, a1b3...to a1b10. Then a2b1, a2b2, a2b3....a2b10. Then a3b1, a3b2, a3b3....a3b10. This should happen until I get a10b1, a10b2, a10b3....a10b10. How would I create this loop?
  4 件のコメント
Rik
Rik 2020 年 10 月 25 日
Maybe meshgrid (or ndgrid) is what you're looking for.
Sunshine
Sunshine 2020 年 10 月 25 日
yes, thanks. meshgrid works.

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

採用された回答

Stephen23
Stephen23 2020 年 10 月 25 日
As Rik suggested:
av = a(:);
bv = b(:);
[X,Y] = ndgrid(1:10);
M = [av(X(:)),bv(Y(:))]
  2 件のコメント
Sunshine
Sunshine 2020 年 10 月 25 日
yes, thanks a bunch. This got me going. I changed ndgrid to meshgrid and that produced the output I was looking for.
Rik
Rik 2020 年 10 月 25 日
I personally prefer ndgrid, as the extension to higher dimensions is more obvious.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by