Unable to filter data with a for loop and replace command
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Andrew Stark
 el 1 de Dic. de 2020
  
    
    
    
    
    Respondida: Walter Roberson
      
      
 el 1 de Dic. de 2020
            AA=Df{1,1};
AA(AA<1|AA>1.25)=0;
BB=Zf{1,1};
 for ii=1:length(AA);
      if AA(ii)==0
          BB(ii)=0;
     end
 end
AAA=replace(AA,0,[])
BBB=replace(BB,0,[])
Zf compliments Df. I am trying to filter data that is between 2 values into a new matrix and then have a matrix with the Zf component matrix that compliments the Df matrix. However, whenever I run this code it gives me the error 
First argument must be a string array, character vector, or cell array of character vectors.
Error in Analyze (line 283)
AAA=replace(AA,0,[])
How can I get a filtered matrix of both?
1 comentario
  Image Analyst
      
      
 el 1 de Dic. de 2020
				Well it says AA is not a "string array, character vector, or cell array of character vectors" but you didn't give us AA.
What does this say?  Don't use semicolons and look in the command window for answers.
AA
whos AA
Please attach Zf and Df in a mat file so we can run your code.  
save('answers.mat', 'Zf', 'Df');
Then use the paper clip icon to attach answers.mat.
Or else give us code how to create those variables.
Respuesta aceptada
  Walter Roberson
      
      
 el 1 de Dic. de 2020
        replace() is a text processing function. You cannot use it to delete numeric values.
AAA = AA(AA ~= 0);
or in this particular case of comparing to 0
AAA = AA(logical(AA))
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Performance and Memory 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!


