Error: Invalid text character. Check for unsupported symbol, invisible character, or pasting of non-ASCII characters.
    8 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
clc;
close all;
clear all;
mass=[140 140 185 135 180 165 240 170 130 160 118 148 140 150 115 130 ]; % lbs
for part=1:16 %participants
    for c=1:4 %conditions: squat vs stoop and close vs far
        clear markers shoulder elbow wrist L5/S1 object
        if c==1
            cond='_squat_close';
        else if c==2
                cond='_squat_far';
        else if c==3
                cond='_stoop_close';
        else
            cond='_stoop_far';
        end
        end
        end
        mass1(part)=mass(part)*4.44822; % to newtons
        filename=['P' num2str(part),cond]; % reads in files
        load([filename, '.mat']);
        trial=['P' num2str(part), cond];
        condition=[cond, num2str(part)];
        Markers=eval([condition, '.Trajectories.Labeled.Data'])./1000;
        markernames=eval([condition, '.Trajectories.Labeled.Labels']);
        markernames(5)={'L5S1'};
        Markers=permute(Markers,[3,1,2]);
        Markers=Markers(:,:,1:3);
        num_marks=length(markernames); % dynamically assess number of markers
        fs.video=eval([condition, '.FrameRate']); % extract sampling frequency of camera system
        [butter_b,butter_a] = butter(4,2*10/fs.video); % Video at 10 Hz
        for i = 1:3 
            Markers(:,1:num_marks,i) = filtfilt(butter_b,butter_a,Markers(:,1:num_marks,i));
        end
        clear markers
        % Name Markers 
        for p = 1:num_marks
            eval(['markers.', markernames{p} '= squeeze(Markers(:,p,1:3));']);
            %                 eval(['markers.', markernames{pa} '= squeeze(Markers(:,pa,1:3));']);
        end; clear Markers
        percent_initial = (0:1/fs.video:(size(markers.shoulder(:,1))-1)/fs.video);
        percent_initial = (percent_initial/percent_initial(end))*100;
        percent_final = (0:100);
        markers.r_shoulder=markers.r_shoulder';
        markers.l_shoulder=markers.l_shoulder';
        markers.elbow=markers.elbow';
        markers.wrist=markers.wrist';
        markers.L5S1=markers.L5S1';
        markers.object=markers.object';
        normalized_marker_r_shoulder=interp1(percent_initial, markers.r_shoulder(1,:), percent_final);
        normalized_marker_l_shoulder=interp1(percent_initial, markers.l_shoulder(1,:), percent_final);
        normalized_marker_elbow=interp1(percent_initial, markers.elbow(1,:), percent_final);
        normalized_marker_wrist=interp1(percent_initial, markers.wrist(1,:), percent_final);
        normalized_marker_l5S1=interp1(percent_initial, markers.L5S1(1,:), percent_final);
        normalized_marker_object=interp1(percent_initial, markers.object(1,:), percent_final);
        xlswrite('data4.xlsx', mass1(part), [num2str(part)], 'KK3');
        if c==1
            xlswrite('data4.xlsx', normalized_marker_r_shoulder', [num2str(part)], 'B3');
            xlswrite('data4.xlsx', normalized_marker_l_shoulder', [num2str(part)], 'C3');
            xlswrite('data4.xlsx', normalized_marker_elbow', [num2str(part)], 'D3');
            xlswrite('data4.xlsx', normalized_marker_wrist', [num2str(part)], 'E3');
            xlswrite('data4.xlsx', normalized_marker_l5S1', [num2str(part)], 'A3');
            xlswrite('data4.xlsx', normalized_marker_object', [num2str(part)], 'F3');
        else if c==2
                xlswrite('data4.xlsx', normalized_marker_r_shoulder', [num2str(part)], 'L3');
                xlswrite('data4.xlsx', normalized_marker_l_shoulder', [num2str(part)], 'M3');
                xlswrite('data4.xlsx', normalized_marker_elbow', [num2str(part)], 'N3');
                xlswrite('data4.xlsx', normalized_marker_wrist', [num2str(part)], 'O3');
                xlswrite('data4.xlsx', normalized_marker_l5S1', [num2str(part)], 'K3');
                xlswrite('data4.xlsx', normalized_marker_object', [num2str(part)], 'P3');
        else if c==3
                xlswrite('data4.xlsx', normalized_marker_r_shoulder', [num2str(part)], 'V3');
                xlswrite('data4.xlsx', normalized_marker_l_shoulder', [num2str(part)], 'W3');
                xlswrite('data4.xlsx', normalized_marker_elbow', [num2str(part)], 'X3');
                xlswrite('data4.xlsx', normalized_marker_wrist', [num2str(part)], 'Y3');
                xlswrite('data4.xlsx', normalized_marker_l5S1', [num2str(part)], 'U3');
                xlswrite('data4.xlsx', normalized_marker_object', [num2str(part)], 'Z3');
        else
            xlswrite('data4.xlsx', normalized_marker_r_shoulder', [num2str(part)], 'FF3');
            xlswrite('data4.xlsx', normalized_marker_l_shoulder', [num2str(part)], 'GG3');
            xlswrite('data4.xlsx', normalized_marker_elbow', [num2str(part)], 'HH3');
            xlswrite('data4.xlsx', normalized_marker_wrist', [num2str(part)], 'II3');
            xlswrite('data4.xlsx', normalized_marker_l5S1', [num2str(part)], 'EE3');
            xlswrite('data4.xlsx', normalized_marker_object', [num2str(part)], 'JJ3');
        end
        end
        end
    end
end
8 comentarios
  Walter Roberson
      
      
 el 27 de Abr. de 2023
				You ran into a problem using eval() when you tried to dynamically generate variable names. Now start to get an idea why we have been telling you that you should not dynamically generate variable names.
After you have done
filename=['P' num2str(part),cond]; % reads in files
please show us the output of
whos('-file', filename)
Respuestas (1)
  Dheeraj
      
 el 9 de Ag. de 2023
        Hi,  
It is a good practice to generate variable names at the compile time as generating them at the run time is not advised as it creates untraceable bugs. You could refer to this link for better understanding. 
0 comentarios
Ver también
Categorías
				Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



