num2str use for a product of two queried variables

3 ビュー (過去 30 日間)
Kenny
Kenny 2022 年 4 月 20 日
コメント済み: Matt J 2022 年 4 月 20 日
With a for loop, num2str works fine querrying a single variable array:
for i = 1:runs
a = num2str(data.x(i));
end
But when I try to use as I needed, i.e. multiply data.x with data.y:
for i = 1:runs
a = numstr(data.x.*data.y(i));
end
I get this error:
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Note: data.x and data.y are both arrays of size 10x1; and the product of the two is only allowed along this "a" line.
Thanks for any tip on this!
  1 件のコメント
Matt J
Matt J 2022 年 4 月 20 日
COpy/paste the full errror message and, ideally, post enough code that we can run and reproduce the error.

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

回答 (1 件)

Matt J
Matt J 2022 年 4 月 20 日
編集済み: Matt J 2022 年 4 月 20 日
Hard to be sure if it's the cause, but in the second version, you have mistyped num2str.
  1 件のコメント
Kenny
Kenny 2022 年 4 月 20 日
Oh I see; I mistyped it in here. But it is okay in the original script.

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

カテゴリ

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