Splitting a cell into two

2 次查看(过去 30 天)
Hi
I am interested in being able to extract one of two numbers that is in a cell and split by a semi-colon.
Image is attached indicating which I want to split.
Any help is greatly appreciated.
Many thanks in advance,
  2 个评论
Geoff Hayes
Geoff Hayes 2020-5-13
Jake - have you already written the code to read the data from the Excel file? If so, are you just reading in the column of interest or all of the columns? Whether you have read it one or all, what is the data type for that column that you wish to split on - is the data being saved as a char/string?
Jake Bowd
Jake Bowd 2020-5-13
Hi Geoff,
I have written the code to read a number of 'trials' in from a file name '.mot'. Essentially reading in a large structure from something similar to Excel.
I have now established how to split the data, however when I put into a for loop, only the last loop is being saved. Below is the script:
for i=1:nwalks
[Maxpeaks]=findpeaks(Results.Knee_Add_R_Torque(i).waveforms(60:100),'SortStr','descend');
Threshold=Maxpeaks(1,1)*Thold; %Determines the threshold for the findpeaks function
[Results.Knee_Add_R_Torque(i).MaxPeaks, Results.Knee_Add_R_Torque(i).Peaklocationpercent]=findpeaks(Results.Knee_Add_R_Torque(i).waveforms,'MinPeakHeight',Threshold,'MinPeakDistance',width);
end
for i=1:nwalks
Results.Ave=Results.Knee_Add_R_Torque(i).MaxPeaks';
end
Any ideas why the two outputs are being replaced to the last loop?

请先登录,再进行评论。

采纳的回答

Ameer Hamza
Ameer Hamza 2020-5-13
编辑:Ameer Hamza 2020-5-13
You need to assign values to elements in a cell array to prevent them from being overwritten
Results.Ave = cell(1,nwalks); % optional initialization for faster execution
for i=1:nwalks
Results.Ave{i}=Results.Knee_Add_R_Torque(i).MaxPeaks';
end
Or maybe you are trying to create a single matrix with the values of MaxPeaks. In that case try
Results.Ave = [Results.Knee_Add_R_Torque.MaxPeaks].';

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by