Error while converting polyshape into double

10 次查看(过去 30 天)
i have building my polyshape of a ship and i'm trying to rotate it depends on "head" value, which is the angle of the ship in radian.
in simple script it rotate absolutely fine, but in main script it find some error because the polyshape cannot convert into double data.
here i attached all my relevant script, the main script is "Kedua_LoopScript.m"
wonder why it cannot works and how to solve it

采纳的回答

Matt J
Matt J 2023-6-20
编辑:Matt J 2023-6-21
You have pre-allocated ShipImg as a numeric double float vector,
ShipImg = ones(1,length(t)); %a double vector of ones
Then instead of trying to insert a number into ShipImg(n) in line 208, you try to assign a polyshape,
ShipImg(n) = ShipImgRotation(rad2deg(head(n)),LPP,B,xG); %right hand side is a polyshape, left side is not
You cannot stick a polyshape object into a memory location reserved for a double float.
  1 个评论
Matt J
Matt J 2023-6-20
编辑:Matt J 2023-6-20
One way to preallocate a vector of polyshapes is,
clear ShipImg
ShipImg(5,1)=polyshape; %pre-allocate
ShipImg(1)=nsidedpoly(4) %assign to the first element in the polyshape vector
ShipImg =
5×1 polyshape array with properties: Vertices NumRegions NumHoles

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Elementary Polygons 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by