Size mismatch ([:? x :?] ~= [:? x :? x :?]).
조회 수: 8 (최근 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!