Size mismatch ([:? x :?] ~= [:? x :? x :?]).
7 次查看(过去 30 天)
显示 更早的评论
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
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
采纳的回答
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
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
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 Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!