size mismatch ([:? * :?] = [:? * :? * :?]

Hello,
Im trying to use MATLAB Coder where im getting size mismatch ([:? * :?] = [:? * :? * :?] at this line
P(onlyLidarStates,onlyLidarStates) = PL;
Where
P = PAll(:,:,1);
onlyLidarStates = false(10,1);
I went through the features mentioned in this below link But not able get the solution for this.
Thanks,
Vimal

2 个评论

If
onlyLidarStates = false(10,1);
then the LHS indexing refers to zero elements of the array P.
If PL is non-empty then that means you are trying to allocate >zero elements to zero elements.
What do you expect to happen if you try to put three cats into zero boxes?
Sorry my question was not clear
Im trying to convert helperRadarLidarFusionFcn into C code using MATLAB coder
Im getting Size mismatch error in this line
P(onlyLidarStates,onlyLidarStates) = PL;
function [x,P] = helperRadarLidarFusionFcn(xAll,PAll)
n = size(xAll,2);
dets = zeros(n,1);
% Initialize x and P
x = xAll(:,1);
P = PAll(:,:,1);
onlyLidarStates = false(10,1);
onlyLidarStates([6 7 10]) = true;
% Only fuse this information with lidar
xOnlyLidar = xAll(onlyLidarStates,:);
POnlyLidar = PAll(onlyLidarStates,onlyLidarStates,:);
% States and covariances for intersection with radar and lidar both
xToFuse = xAll(~onlyLidarStates,:);
PToFuse = PAll(~onlyLidarStates,~onlyLidarStates,:);
% Sorted order of determinants. This helps to sequentially build the
% covariance with comparable determinations. For example, two large
% covariances may intersect to a smaller covariance, which is comparable to
% the third smallest covariance.
for i = 1:n
dets(i) = det(PToFuse(1:2,1:2,i));
end
[~,idx] = sort(dets,'descend');
xToFuse = xToFuse(:,idx);
PToFuse = PToFuse(:,:,idx);
% Initialize fused estimate
thisX = xToFuse(:,1);
thisP = PToFuse(:,:,1);
% Sequential fusion
for i = 2:n
[thisX,thisP] = fusecovintUsingPos(thisX, thisP, xToFuse(:,i), PToFuse(:,:,i));
end
% Assign fused states from all sources
x(~onlyLidarStates) = thisX;
P(~onlyLidarStates,~onlyLidarStates,:) = thisP;
% Fuse some states only with lidar source
valid = any(abs(xOnlyLidar) > 1e-6,1);
xMerge = xOnlyLidar(:,valid);
PMerge = POnlyLidar(:,:,valid);
if sum(valid) > 1
[xL,PL] = fusecovint(xMerge,PMerge);
elseif sum(valid) == 1
xL = xMerge;
PL = PMerge;
else
xL = 0;
PL = 1;
end
x(onlyLidarStates) = xL;
P(onlyLidarStates,onlyLidarStates) = PL;
end
This is what im trying to do. Please help me get me through this.

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by