Size mismatch ([:? x :?] ~= [:? x :? x :?]).
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Vimal Prasath
le 20 Mai 2020
Commenté : Wilson A N
le 1 Juin 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 commentaires
Wilson A N
le 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
Réponse acceptée
Wilson A N
le 21 Mai 2020
Modifié(e) : Wilson A N
le 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 commentaires
William Mok
le 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
le 1 Juin 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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!