Grabbing the first position in cell within a structure

1 次查看(过去 30 天)
Hello all,
I'm attempting to grab the first, second, third and then fourth position of a vector, where each row representing a different object has a 1X4 cell; object . How could i do this using a for loop?
I currently have the vector within a struct (outputTableExport), object= [5 6 5 8; 9 6 4 3; 9 8 5 2] ect.... im trying to create a varables utalizing matlabs 'patch' function to turn 'object' into something like this: newVariable = [5 9 9];[6 6 8];[5 4 5];[8 3 2]. In this example is would be turning this nX4 into a 4Xn where n = the number of objects. The code below is what ive tried so far.
Any help or guidance would be appreciated.
for iRun = 1:1:length(outputTableExport)
for iObj = 1:1:length(outputTableExport(iRun).tubingRuns)
xArrayObject{1,iObj} = outputTableExport(iRun).tubingRuns(iObj).xArray(1);
yArrayObject(1,iObj) = outputTableExport(iRun).tubingRuns(iObj).yArray(1);
xArrayObject{2,iObj} = outputTableExport(iRun).tubingRuns(iObj).xArray(2);
yArrayObject(2,iObj) = outputTableExport(iRun).tubingRuns(iObj).yArray(2);
xArrayObject{3,iObj} = outputTableExport(iRun).tubingRuns(iObj).xArray(3);
yArrayObject(3,iObj) = outputTableExport(iRun).tubingRuns(iObj).yArray(3);
xArrayObject{4,iObj} = outputTableExport(iRun).tubingRuns(iObj).xArray(4);
yArrayObject(4,iObj) = outputTableExport(iRun).tubingRuns(iObj).yArray(4);
end
end

采纳的回答

Ikenna Okoye
Ikenna Okoye 2020-5-15
I figured it out.
xArrayObject(1,iObj) = outputTableExport(iRun).tubingRuns(iObj).xArray(1);
Cant be in cell array format.

更多回答(0 个)

类别

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

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by