I create these columns from a for loop. idx are indexes eg idx=[2 3 45].
Area ,Eccentricity etc are regionprops.
Each Pollen has an Area ,an Eccentricity,an Euler etc
I try to save to json by creating a structure.I use saveJSONfile from Matlab Exchange
i have this problem
for j=1:length(idx)
Pollen(j,:)=j;
Area(j,:)=area(idx(j)).Area;
Eccentricity(j,:)=eccentricity(idx(j)).Eccentricity ;
Euler(j,:)=euler(idx(j)).EulerNumber;
Perimeter(j,:)=perimeter(idx(j)).Perimeter;
Orientation(j,:)=orientation(idx(j)).Orientation;
end
data.Pollen=Pollen'
data.Area=Area'
data.Eccentricity=Eccentricity'
data.Euler=Euler'
data.Perimeter=Perimeter'
data.Orientation=Orientation'
fullFileNameJason=fullfile(folder,'SingleValues.json');
saveJSONfile(data, fullFileNameJason);

Respuestas (1)

KSSV
KSSV el 29 de En. de 2019

0 votos

Check the way you are creating the structure....Read about structure
S = struct ;
for i=1:3
S(i).Pollen = rand(1,3) ;
S(i).Area = rand(1,3) ;
end

6 comentarios

i tried and it gives me only the first value of the matrices
data=struct;
for i=1:numel(Pollen)
data(i).Pollen=Pollen(i,1);
data(i).Area=Area(i,1);
data(i).Eccentricity=Eccentricity(i,1);
data(i).Euler=Euler(i,1);
data(i).Perimeter=Perimeter(i,1);
data(i).Orientation=Orientation(i,1);
end
fullFileNameJason=fullfile(folder,'SingleValues.json');
saveJSONfile(data, fullFileNameJason);
KSSV
KSSV el 29 de En. de 2019
YOu need to include another loop to fill more values.
DIMITRIOS THEODOROPOULOS
DIMITRIOS THEODOROPOULOS el 29 de En. de 2019
The matrices are columns /rows.. as i showed in picture..
How can i do it then with 2 for loops??
I am a beginner..
KSSV
KSSV el 29 de En. de 2019
data=struct;
for i=1:numel(Pollen)
for j = 1:4
data(i).Pollen=Pollen(i,j);
data(i).Area=Area(i,j);
data(i).Eccentricity=Eccentricity(i,j);
data(i).Euler=Euler(i,j);
data(i).Perimeter=Perimeter(i,j);
data(i).Orientation=Orientation(i,j);
end
end
fullFileNameJason=fullfile(folder,'SingleValues.json');
saveJSONfile(data, fullFileNameJason);
DIMITRIOS THEODOROPOULOS
DIMITRIOS THEODOROPOULOS el 29 de En. de 2019
Index exceeds matrix dimensions.......
says.....
KSSV
KSSV el 29 de En. de 2019
You need to fix the loop j...may be it takes values from 1:3.

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 29 de En. de 2019

Comentada:

el 29 de En. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by