Data Interpolation using interp1
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Barbara Schläpfer
 il 8 Dic 2020
  
    
    
    
    
    Commentato: Walter Roberson
      
      
 il 11 Dic 2020
            Hi 
I am trying to interpolate different data sets, so that they all have the same size for my further analysis.
        maxLength = max([length(unique_expperimental_dis), length(unique_experimental_force), length(abaqus_force)]);
        xFit = 1:maxLength;
        experimental_dis_interp = interp1(1:length(unique_expperimental_dis), unique_expperimental_dis, xFit);
        size('experimental_dis_interp')
        experimental_force_interp = interp1(1:length(unique_experimental_force), unique_experimental_force, xFit);
        size('experimental_force_interp')
        abaqus_force_interp = interp1(1:length(abaqus_force), abaqus_force, xFit);
        size('abaqus_force_interp')
But wenn I read out the sizes of the different data sets, they do not match eachother. Any suggestions what I am doing wrong?
Barbara
Risposta accettata
  Walter Roberson
      
      
 il 8 Dic 2020
        
      Modificato: Walter Roberson
      
      
 il 8 Dic 2020
  
              maxLength = max([length(unique_expperimental_dis), length(unique_experimental_force), length(abaqus_force)]);
        xFit = 1:maxLength;
        experimental_dis_interp = interp1(1:length(unique_expperimental_dis), unique_expperimental_dis, xFit);
        size(experimental_dis_interp)
        experimental_force_interp = interp1(1:length(unique_experimental_force), unique_experimental_force, xFit);
        size(experimental_force_interp)
        abaqus_force_interp = interp1(1:length(abaqus_force), abaqus_force, xFit);
        size(abaqus_force_interp)
You were calculating the size() of the character vectors, not the variables.
Caution: you have not turned on extrapolation, so the above code is equivalent to padding the short vectors with NaN.
2 Commenti
  Walter Roberson
      
      
 il 11 Dic 2020
				If padding with NaN was not your intention, then you need to be more clear about your desired outcome.
If you have two variables in which there is a linear relationship between the two, so (say) 2/3 of the way through the range of one should correspond to 2/3 of the way through the range of the other, then you can scale between them:
fraction_through_first_range = (value_in_first_range - minimum_of_first_range) / (maximum_of_first_range - minimum_of_first_range);
projected_into_second_range = minimum_of_second_range + (maximum_of_second_range - mininum_of_second_range) * fraction_through_first_range
Is it really the number of different entries in a group that matters to you, or are you wanting to project by portion of the way through the respective range?
linspace(unique_expperimental_dis(1), unique_expperimental_dis(end), maxLength)
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


