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

Stephen23
Stephen23 2020년 4월 30일
편집: Stephen23 2020년 4월 30일
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?
Vimal Prasath
Vimal Prasath 2020년 4월 30일
편집: Vimal Prasath 2020년 4월 30일
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개)

질문:

2020년 4월 30일

편집:

2020년 4월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by