Effacer les filtres
Effacer les filtres

Grabbing the first position in cell within a structure

2 vues (au cours des 30 derniers jours)
Ikenna Okoye
Ikenna Okoye le 15 Mai 2020
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

Réponse acceptée

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

Plus de réponses (0)

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by