Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
Vimal Prasath
Vimal Prasath am 20 Mai 2020
Kommentiert: Wilson A N am 1 Jun. 2020
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 Kommentare
Wilson A N
Wilson A N am 20 Mai 2020
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 am 20 Mai 2020
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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Wilson A N
Wilson A N am 21 Mai 2020
Bearbeitet: Wilson A N am 21 Mai 2020
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 Kommentare
William Mok
William Mok am 30 Mai 2020
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 am 1 Jun. 2020
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by