Bonjour à tous,

Je fais une nouvelle fois appel à vos service car je suis dans une impasse !

Mon code comporte trois fonctions : main, loading et movies

Les deux premières fonctionnent comme je veux mais la dernière me pose quelques problèmes. J'ai besoin de récupérer deux paramètres lus par la fonction loading (qui load un fichier htr beaucoup trop volumineux pour vous le joindre). Ces paramètres sont EulerRotationOder et Data qui sont respectivement une chaîne de caractères et un tableau contenant 1 ligne sur 2999 colonnes et dans chacune de ces cellules est contenue une matrice 27*7.

Je voudrais donc récupérer ces deux paramètres dans ma fonction movie. Ma je n'arrive même pas à récupérer la chaîne de caractère alors les Data j'en parle même pas

Je vous joins le code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
 
function main
 
figure('units','pixels',...
'position',[250 250 1000 1000],...
'color',[0.925 0.913 0.687],...
'numbertitle','off',...
'name','[GUI] HTR files treatment',...
'menubar','none',...
'tag','interface');
 
uicontrol('style','pushbutton',...
'units','normalized',...
'position',[0.2 0.01 0.1 0.05],...
'string','OK',...
'callback',@load,...
'tag','bouton_ok');
 
uicontrol('style','pushbutton',...
'units','normalized',...
'position',[0.6 0.5 0.15 0.1],...
'string','Simulate',...
'callback',@simulate,...
'tag','simulate');
 
uipanel('Title','Display on Matlab window',...
             'Position',[.05 .15 .5 .8]);
 
uicontrol('style','edit',...
'units','normalized',...
'position',[0.1 0.07 0.3 0.05],...
'string','filename.htr',...
'tag','filename');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.85 0.3 0.05],...
'string','FileType',...
'tag','FileType');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.80 0.3 0.05],...
'string','FileName',...
'tag','FileName');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.75 0.3 0.05],...
'string','DataType',...
'tag','DataType');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.70 0.3 0.05],...
'string','FileVersion',...
'tag','FileVersion');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.65 0.3 0.05],...
'string','NumSegments',...
'tag','NumSegments');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.60 0.3 0.05],...
'string','NumFrames',...
'tag','NumFrames');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.55 0.3 0.05],...
'string','DataFrameRate',...
'tag','DataFrameRate');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.50 0.3 0.05],...
'string','EulerRotationOrder',...
'tag','EulerRotationOrder');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.45 0.3 0.05],...
'string','CalibrationUnits',...
'tag','CalibrationUnits');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.40 0.3 0.05],...
'string','RotationUnits',...
'tag','RotationUnits');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.35 0.3 0.05],...
'string','GlobalAxisOfGravity',...
'tag','GlobalAxisOfGravity');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.3 0.3 0.05],...
'string','BoneLengthAxis',...
'tag','BoneLengthAxis');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.25 0.3 0.05],...
'string','ScaleFactor',...
'tag','ScaleFactor');
 
uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.1 0.2 0.3 0.05],...
'string','Structure',...
'tag','Structure');
 
data=guihandles(gcf);
 
data.eulerRotationOrder = 'XYZ';
 
guidata(gcf,data)
 
function load(obj,event)
 
data=guidata(gcbf);
 
Structure = get(data.Structure,'Value');
filename = get(data.filename,'String');
FileName = get(data.FileName,'Value');
FileType = get(data.FileType,'Value');
DataType = get(data.DataType,'Value');
FileVersion = get(data.FileVersion,'Value');
NumSegments = get(data.NumSegments,'Value');
NumFrames = get(data.NumFrames,'Value');
DataFrameRate = get(data.DataFrameRate,'Value');
EulerRotationOrder = get(data.EulerRotationOrder,'Value');
CalibrationUnits = get(data.CalibrationUnits,'Value');
RotationUnits = get(data.RotationUnits,'Value');
GlobalAxisOfGravity = get(data.GlobalAxisOfGravity,'Value');
BoneLengthAxis = get(data.BoneLengthAxis,'Value');
ScaleFactor = get(data.ScaleFactor,'Value');
 
NumberofHTRfile = 1;
k = NumberofHTRfile;
 
for i=1:1:k
 
    file{i}=filename;
 
    fid{i} = fopen(file{i},'rt');
 
    format = '%s %s %s %s %s %s %s %s' ;
    rus{i} = textscan(fid{i},format);
    HTRfile{i} = [rus{i}{:}];
 
 
%------------------------------------------------------------------------
%HEADER
%------------------------------------------------------------------------
ref=HTRfile{i};
 
HTRStructure(i).FileName = file{1,i};
HTRStructure(i).FileType = ref{4,2};
HTRStructure(i).DataType = ref{5,2};
HTRStructure(i).FileVersion = str2double(ref{6,2});
HTRStructure(i).NumSegments = str2double(ref{7,2});
HTRStructure(i).NumFrames = str2double(ref{8,2});
HTRStructure(i).DataFrameRate = str2double(ref{9,2});
HTRStructure(i).EulerRotationOrder = ref{10,2};
 
data.eulerRotationOrder = HTRStructure(i).EulerRotationOrder
 
HTRStructure(i).CalibrationUnits = ref{11,2};
HTRStructure(i).RotationUnits = ref{12,2};
HTRStructure(i).GlobalAxisOfGravity = ref{13,2};
HTRStructure(i).BoneLengthAxis = ref{14,2};
HTRStructure(i).ScaleFactor = str2double(ref{15,2});
 
%------------------------------------------------------------------------
%Hierarchy
%------------------------------------------------------------------------
 
HTRStructure(i).SegmentNamesHierarchy = ref(18:44,1:2);
 
%------------------------------------------------------------------------
%Base Position
%------------------------------------------------------------------------
 
HTRStructure(i).BasePosition = ref(47:73,2:8);
 
%------------------------------------------------------------------------
%All Frames
%------------------------------------------------------------------------
 
NS = HTRStructure(i).NumSegments;
NF = HTRStructure(i).NumFrames;
Start = 23+2*NS;
Step = NF+2;
 
t=1;
 
for m = 1:1:(NF-1)
 
    Data{i,t}=reshape(str2num(str2mat(ref(Start+m:Step:Start+m+(NS-1)*Step,2:8))),27,7);
    t=t+1;
 
end
 
   Data{i,1}=reshape(str2num(str2mat(ref(47:73,2:8))),27,7);
 
   data.Data = reshape(str2num(str2mat(ref(47:73,2:8))),27,7);
 
   HTRStructure(i).Data = Data(i,:) ;
 
   if Structure == 1
   HTRStructure(i)
   end
   if FileName == 1
   HTRStructure(i).FileName
   end
   if FileType == 1
   HTRStructure(i).FileType
   end
   if DataType == 1
   HTRStructure(i).DataType
   end
   if FileVersion == 1
   HTRStructure(i).FileVersion
   end
   if NumSegments == 1
   HTRStructure(i).NumSegments
   end
   if NumFrames == 1
   HTRStructure(i).NumFrames
   end
   if DataFrameRate == 1
   HTRStructure(i).DataFrameRate
   end
   if EulerRotationOrder == 1
   HTRStructure(i).EulerRotationOrder
   end
   if CalibrationUnits == 1
   HTRStructure(i).CalibrationUnits
   end
   if RotationUnits == 1
   HTRStructure(i).RotationUnits
   end
   if GlobalAxisOfGravity == 1
   HTRStructure(i).GlobalAxisOfGravity
   end
   if BoneLengthAxis == 1
   HTRStructure(i).BoneLengthAxis
   end
   if ScaleFactor == 1
   HTRStructure(i).ScaleFactor
   end
 
end
guidata(gcbf,data)
 
function simulate(obj,event)
 
data=guidata(gcbf);
 
a=get(data.eulerRotationOrder,'String');
b=get(data.Data);
 
base = a;
Data = b;
 
Data{1,1} = reshape(str2num(str2mat(BasePosition)),27,7);
 
Data{1,1}(1,4) = Data{1,1}(1,4)+90;
Data{1,1}(1,5) = 0;
Data{1,1}(1,6) = 0;
 
xmin=-1000;
xmax=1000;
ymin=0;
ymax=2000;
zmin=-1000;
zmax=1000;
 
%M=moviein(j);
SegmentLine=zeros(1,27); % Preallocate 27 places for segmentline matrix
colorring=['k' 'r' 'g' 'b']; %used to cycle the line colors of the segments
 
for i=1:27 % creates 27 lines and assign the primary attributes: color, width, etc.
    SegmentLine(i)=line;
    set(SegmentLine(i), 'linewidth',2,'color', colorring(mod(i,4)+1), 'marker', '*', 'markersize', 6);
end
 
box on
axis([xmin xmax ymin ymax zmin zmax])
view(3)
 
for j=SOF:2:(EOF-1)
 
    for i=1:27
 
        if i==1 % DaveRoot
            q=[0,0,0]';
            s=R(0,0,0,base);
        elseif i==2 % Pelvis
            q=p(:,1);
            s=r(:,:,1);
        elseif i==3 % Spine1
            q=p(:,1);
            s=r(:,:,1);
        elseif i==4 % Lefthip
            q=p(:,1);
            s=r(:,:,1);
        elseif i==9 % Righthip
            q=p(:,1);
            s=r(:,:,1);
        elseif i==14 % Spine2
            q=p(:,i-11);
            s=r(:,:,i-11);
        elseif i==17 % Neck
            q=p(:,i-1);
            s=r(:,:,i-1);
        elseif i==20 % L Clavicle
            q=p(:,i-4);
            s=r(:,:,i-4);
        elseif i==24 % R Clavicle
            q=p(:,i-8);
            s=r(:,:,i-8);
 
        else
            q=p(:,i-1);
            s=r(:,:,i-1);
        end
 
        p(:,i)=q+s*[Data{1,1}(i,1),Data{1,1}(i,2),Data{1,1}(i,3)]';
        r(:,:,i)=s*R(Data{1,1}(i,4),Data{1,1}(i,5),Data{1,1}(i,6),base)*R(Data{1,j}(i,4),Data{1,j}(i,5),Data{1,j}(i,6),base);
        v=Data{1,1}(i,7)*r(:,2,i);
 
        %line(p(1,i)+[0,v(1)],p(2,i)+[0,v(2)],p(3,i)+[0,v(3)],'color','k')
        set(SegmentLine(i),'xdata',(p(1,i)+[0,v(1)]),'ydata',(p(2,i)+[0,v(2)]),'zdata',(p(3,i)+[0,v(3)]));
        % line(p(1,i)+k*[0,r(1,1,i)],p(2,i)+k*[0,r(2,1,i)],p(3,i)+k*[0,r(3,1,i)],'color','r')
        % line(p(1,i)+k*[0,r(1,2,i)],p(2,i)+k*[0,r(2,2,i)],p(3,i)+k*[0,r(3,2,i)],'color','g')
        % line(p(1,i)+k*[0,r(1,3,i)],p(2,i)+k*[0,r(2,3,i)],p(3,i)+k*[0,r(3,3,i)],'color','b')
    end
    drawnow
    pause(0);
    %set(findobj('type','line'),'linewidth',2);
    %set(findobj('type','line','color','k'),'linewidth',2);
    %box on
    %axis([xmin xmax ymin ymax zmin zmax])
    %view(3)
 
    %axis equal
    %xlabel('x')
    %ylabel('y')
    %zlabel('z')
 
 
    %M(:,1)=getframe;
    %clf
 
end
close all;
clear all;
Pourtant j'utilise la méthode classique (lignes 118 120 122) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
data=guihandles(gcf);
 
data.eulerRotationOrder = 'XYZ';
 
guidata(gcf,data)
Ensuite ligne 178 je "set" la nouvelle valeur qui a été trouvé dans le fichier chargé (j'ai essayé la ligne en commentaire ci-après et ça ne fonctionne pas !)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
data.eulerRotationOrder = HTRStructure(i).EulerRotationOrder;
 
% set(data.eulerRotationOrder,'String',HTRStructure(i).EulerRotationOrder);
Ligne 260 je récupère les nouvelles valeurs (enfin je n'en suis plus très sûr maintenant)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
guidata(gcbf,data)
Et je récupère toute ces valeurs de nouveau dans la 3ème fonction "movies"
et utilise la fonction get (de la même analogue à la 2ème fonction ligne 128-142) mais là, problème

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
function simulate(obj,event)
 
data=guidata(gcbf);
 
a=get(data.eulerRotationOrder,'String');
b=get(data.Data);
 
base = a;
Data = b;
et voici le message d'erreur :

??? Error using ==> get
Invalid handle

Error in ==> main>simulate at 266
a=get(data.eulerRotationOrder,'Value')

??? Error while evaluating uicontrol Callback
Si quelqu'un a une idée... je suis preneur. Merci d'avance.