num2str use for a product of two queried variables

조회 수: 1 (최근 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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by