num2str use for a product of two queried variables

1 view (last 30 days)
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 Comment
Matt J
Matt J on 20 Apr 2022
COpy/paste the full errror message and, ideally, post enough code that we can run and reproduce the error.

Sign in to comment.

Answers (1)

Matt J
Matt J on 20 Apr 2022
Edited: Matt J on 20 Apr 2022
Hard to be sure if it's the cause, but in the second version, you have mistyped num2str.
  1 Comment
Kenny
Kenny on 20 Apr 2022
Oh I see; I mistyped it in here. But it is okay in the original script.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!