Size mismatch ([:? x :?] ~= [:? x :? x :?]).

7 ビュー (過去 30 日間)
Vimal Prasath
Vimal Prasath 2020 年 5 月 20 日
コメント済み: Wilson A N 2020 年 6 月 1 日
Hello,
I'm trying to convert my program into C/C++ code. but when i tried to convert my code using matlab coder i'm getting error "Size mismatch ([:? x :?] ~= [:? x :? x :?])" at 60th line inside the helperRadarLidarFusionFcn.
P(onlyLidarStates,onlyLidarStates) = PL;
at this line "P(onlyLidarStates,onlyLidarStates)" size was Inf x:Inf and "PL " size was Inf x:Inf x:Inf
I'm attaching the helperRadarLidarFusionFcn.m file
How do i clear this error?
  2 件のコメント
Wilson A N
Wilson A N 2020 年 5 月 20 日
Hi Vimal,
Can you provide the compilation inputs you are providing to the function. This would help to recreate the issue.
I tried using the following command on the function and it seems to work (assuming first is 2 dimensional input and second argument is 3 dimensional)
codegen helperRadarLidarFusionFcn -args {coder.typeof(2,[Inf Inf]),coder.typeof(2,[Inf Inf Inf])}
-Wilson
Vimal Prasath
Vimal Prasath 2020 年 5 月 20 日
I tried the same command that you used above, Still i'm getting the same errors
>> codegen helperRadarLidarFusionFcn -args {coder.typeof(2,[Inf Inf]),coder.typeof(2,[Inf Inf Inf])}
??? Size mismatch ([:? x :?] ~= [:? x :? x :?]).
Error in ==> helperRadarLidarFusionFcn Line: 60 Column: 1
Code generation failed: View Error Report
Error using codegen
I dont know why it is happening, Please help me solving this issue
-Vimal

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

採用された回答

Wilson A N
Wilson A N 2020 年 5 月 21 日
編集済み: Wilson A N 2020 年 5 月 21 日
Hi Vimal,
I was able to reproduce the issue with MATLAB R2019b. Based on my observations, can you try changing the code in line no 49-60 to the following:
if sum(valid) > 1
[xL,PL] = fusecovint(xMerge,PMerge);
P(onlyLidarStates,onlyLidarStates) = PL;
elseif sum(valid) == 1
xL = xMerge;
PL = PMerge;
P(onlyLidarStates,onlyLidarStates) = PL(:,:,1);
else
xL = 0;
PL = 1;
P(onlyLidarStates,onlyLidarStates) = PL;
end
x(onlyLidarStates) = xL;
% P(onlyLidarStates,onlyLidarStates) = PL;
From my understanding of the error message, there is a dimension mismatch that was taking place. So, I explicitly specified the PL variable with dimensions before assigning it to variable P in each path of the if else condition.
In the elseif condition I gave PL(:,:,1) as only when valid = 1, then sum(valid) = 1.
I was able to compile successfully with this small modification.
Hope it helps.
- Wilson
  2 件のコメント
William Mok
William Mok 2020 年 5 月 30 日
Hi Wilson,
Can you please help to check this code too? I got the same error when converting to C/C++ using the coder in line 84.
Thanks in advance.
Regards,
William
Wilson A N
Wilson A N 2020 年 6 月 1 日
Hi William,
I tried the following command with the attached file, but I was unable to reproduce the issue
codegen AGCWD -args {coder.typeof(3,[Inf Inf])}
But by just looking at the code, I think the issue can be fixed by just rewriting line 84 with a simple nested for loop.
Line 84 is used to assign the values to 'color_image' from 'value_channel'. Now, explicitly specifying which values to assign to which elements would likely resolve the issue. A pseudocode for the above can look something like below:
for (i = 1; i < size(value_channel,1);i++)
for (j = 1; i < size(value_channel,2);i++)
color_image(i,j,3) = value_channel(i,j);
end
end
Hope it helps :)
- Wilson

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by