Unable to perform assignment because brace indexing is not supported for variables of this type
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ram Prasanth
am 25 Mär. 2024
Kommentiert: Ram Prasanth
am 26 Mär. 2024
Hello Everyone,
Hope you all are doing well.
I have a question for ADAS Programmation.
Where i am trying to create an object using the class file and Initially i have defined the variable name as left line and right lines of the road.
But now i am trying to automate the lines detected and the data populated must be segregated for the simulation purpose.
But i get an error of brace indexing is not supported.
My code is:
IdxLines = numel(simout.logsout.get("<B_x_VS_LaneBoundaries>"). ...
Values.LaneBoundaries);
for IdxLines = 1:5
sLineMajor{IdxLines,:} = simout.logsout.get("<B_x_VS_LaneBoundaries>").Values.LaneBoundaries(IdxLines);
vLineWidth{IdxLines,:} = sLineMajor(IdxLines,:).Width.Data(:); % Lane boundary Width
vLineHeadingAngle{IdxLines,:} = sLineMajor(IdxLines,:).HeadingAngle.Data;
vLineType{IdxLines,:} = sLineMajor(IdxLines,:).BoundaryType.Data(:); % Lane type 1 - Solid, 2 - Dashed
vLinexpos{IdxLines,:} = sLineMajor(IdxLines,:).Coordinates.Data(:,1,:); % xpos of the line
vLineypos{IdxLines,:} = sLineMajor(IdxLines,:).Coordinates.Data(:,2,:); % ypos of the line
vLineQuality{IdxLines,:} = sLineMajor(IdxLines,:).Strength.Data(:); % Represents the Line Quality,
oLine{IdxLines,:} = roadLines(vLineWidth,10,vLineHeadingAngle, ...
vLineQuality,vLineType,vLinexpos,vLineypos);
end
Class def file:
classdef roadLines
% Class for defining line properties
properties (Access = public)
Width; % Width of the Line specified on the simulink file
viewRange;
headingAngle;
Quality;
Type; % Type of Line dashed, double lines, solid, dotted and non continuous
xPos; % Y Position of the Line
yPos; % X Position of the Line
Style; % Derived based on the type
end
methods
% Constructor
function obj = roadLines(Width,viewRange, headingAngle, ...
Quality, vType, xPos, yPos)
obj.Width = Width;
obj.viewRange = viewRange;
obj.headingAngle = headingAngle;
% obj.curvature = curvature; % Currently
% commented out as it is not used anywhere
% obj.curvatureDerviative = curvatureDerviative;
obj.Quality = Quality;
obj.Type = vType;
obj.xPos = xPos;
obj.yPos = yPos;
obj.Style = setStyle(obj);
end
function cDisplayStyle = setStyle(lineProperties)
vType = lineProperties.Type;
% Initialize the output cell array with nan values
cDisplayStyle = cell(length(vType), 1);
% Loop over each time step
for idx_Time = 1:numel(vType)
if vType(idx_Time) == 1 % 1= Solid line
cDisplayStyle{idx_Time} = '-';
elseif vType(idx_Time) == 2 % 2 = Dashed line
cDisplayStyle{idx_Time} = '--';
else % Any other line type is affected to "-." style
cDisplayStyle{idx_Time} = '-.';
end
end
end % end displayLineStyle
end
end
I am sorry i cannot provide the data's as it is confidential.
but i can say that the data's inside lane boundaries are in the format of structs and inside it is the format of time series and each time series is specified as a vector of 3 Dimensioned matrix.
So basically my idea is. That my code needs to extract data's in to multiple objects Like Line1, Line2, Line3 and etc. and the object collections must be formed in to a struct.
The Struct formation is already done and object collection is also done but i am just stuck in this automatic indexing incrementation.
and the incrementation of number must occur automatically.
Thank you for all the answers and support in Advance.
If my question is not clear kindly comment and i will try to clarify it.
1 Kommentar
Akzeptierte Antwort
VBBV
am 25 Mär. 2024
Bearbeitet: VBBV
am 25 Mär. 2024
Try the folliowing
sLineMajor = simout.logsout.get("<B_x_VS_LaneBoundaries>").Values.LaneBoundaries(IdxLines);
vLineWidth{IdxLines,:} = sLineMajor.Width.Data(:); % Lane boundary Width
vLineHeadingAngle{IdxLines,:} = sLineMajor.HeadingAngle.Data;
4 Kommentare
VBBV
am 25 Mär. 2024
Bearbeitet: VBBV
am 25 Mär. 2024
Since you want code to extract data from struct fields as objects , it's better to use ( ) than { } However, the field data of all structs will be present in remaining variables, pls check vLineWidth ,it will contain data from all 4 structs
sLineMajor(IdxLines) = simout.logsout.get("<B_x_VS_LaneBoundaries>").Values.LaneBoundaries(IdxLines);
vLineWidth{IdxLines,:} = sLineMajor(IdxLines).Width.Data(:)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Testing Frameworks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!