Borrar filtros
Borrar filtros

Undefined function 'colon' for input arguments of type 'double' and attributes 'full 3d real'.

7 visualizaciones (últimos 30 días)
Hello,
I am trying to analyze some data from CFSFile, this are very noisy and little currents I need to take. I am currently Using excel to determine the cell and type of experiment I did. So, I have an excel file with multiple sheets with different experiments. I am working on my code, so far I made it simple so I can control that what is doing is right.
So I want to take the maximum value in a range, then around that number find several more peaks like that and calculate a mean of those peaks, later do the same for the minimum and finally subtract max and min. (I try peak to peak but it only calculates 1 max and 1 min, and is very noisy, so I need to average more peaks. Each cell has 5 traces. I need to calculate for each one. In matlab the input is a row a trace. Sum up, I have 3 excel sheets, with cells inside each sheet, with 5 traces each cell. Need to take max and min from each and subtract.
if true
for jj = 1:numel(sheets)
%some more info about the excel....
for ii = 1:CellNum
input=[];
fName=sprintf('%3.3d_%3.3d.cfs',Excel(ii,1),Excel(ii,2));
input=ReadCFSFile(cfsdir, fName, chan_num,0);
%the code I am trying to make work,
[valmax, idxmax]= max(input.current(:,1004:1031),[],2);
indexFromZero(:,ii,jj)=1004+idxmax-1;
MaximumMean(:,ii,jj)= mean(input.current(:,indexFromZero-1:indexFromZero+1),2);
indexMinimumRange(:,ii,jj)=indexFromZero (:,ii) +40;
MINVal (:,ii,jj)= min(input.current(:,1056:1058),[],2);
MinmumMean(:,ii,jj)=mean(input.current(:,indexFromZero-1:indexFromZero+1),2);
end
I haven't finished, but it calculates correctly until it needs to go to the second sheet, then it says:
_Undefined function 'colon' for input arguments of type 'double' and attributes 'full 3d real'.
Error in Ih1 MaximumMean(:,ii,jj)= mean(input.current(:,indexFromZero-1:indexFromZero+1),2);_
I can't find a solution. It only happens when it tries to go to the second sheet of excel and start the analysis of the second set of data. I am new at using matlab, probably it is something simple but I really can't fix it. Thank you in advanced.

Respuesta aceptada

Walter Roberson
Walter Roberson el 27 de Jun. de 2017
Replace
MaximumMean(:,ii,jj)= mean(input.current(:,indexFromZero-1:indexFromZero+1),2);
with
temp = mean(input.current(:,cat(3,indexFromZero-1, indexFromZero, indexFromZero+1)),2);
MaximumMean(:,ii,jj) = temp;
This probably will allow the indexing of input.current to work. The result of the indexing will be 3D, so the mean() with result to dimension 2 will be 3D with middle dimension of length 1. This will then be the wrong size for the assignment... but at least you would have gotten through the mean.
What you probably need is to use sub2ind() to build indices to retrieve the data you are looking for; I show that with regards to a 3D array at https://www.mathworks.com/matlabcentral/answers/346213-cummean-along-elements-of-3d-matrix#comment_464381. That will remove problems with extracting more information than you expect to extract (like my incorrect code that is posted a few comments above that link.)
However, once you get the indexing right, you are still going to have the problem that you are working with 3D arrays, and the mean() of that along the 2nd dimension is going to be 3D and so will not fit into the vector location you are attempting to assign to. You need to rethink that part. For example perhaps you only need to worry about extracting from indexFromZero(:,ii,jj) rather than all of indexFromZero including all of the columns and hyperplanes you assigned to on previous iterations (and including all the failures you will get because when you use all of indexFromZero you are going to be including the portions that are still 0 because you have not assigned to them yet.)
  2 comentarios
Milagros ARIETTI
Milagros ARIETTI el 27 de Jun. de 2017
Hello!
Thank you for the fast answer, I tried what you suggested but gives an error again,
if true
Subscript indices must either be real positive integers or logicals.
Error in Ih3 (line 51)
temp = mean(input.current(:,cat(3,indexFromZero-1, indexFromZero,indexFromZero+1)),2);
end
I will try to see if I can solve it also with the other post. I understand what you say, I was afraid it was going to be something like this :( BUT THANK YOU!
Walter Roberson
Walter Roberson el 27 de Jun. de 2017
See the part above where I wrote,
"(and including all the failures you will get because when you use all of indexFromZero you are going to be including the portions that are still 0 because you have not assigned to them yet.)"

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by