Effacer les filtres
Effacer les filtres

how to concatenate rows of different sizes over an array of the minimum size among these rows?

2 vues (au cours des 30 derniers jours)
I want to concatenate 32 columns from different 32 files sequentially named. The code works fine if the the 32 files have similar size arrays(2500 in some of the sets); however, other sets of 32 files have one file of size 2909 or more. Now I need to consider all the concatenation to be over the first 2500 only. Please help in editing the code below (error message is below as well):
clear all size=2500; for i=1 : 32 filename=horzcat(pwd,'\Run4915_Inj',int2str(i),'.pre'); delimiter = {'\t',','}; startRow = 3; %% Format string for each line of text: formatSpec = '%f%f%f%*s%[^\n\r]';
%% Open the text file. fileID = fopen(filename,'r');
%% Read columns of data according to format string. dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'HeaderLines' ,startRow-1, 'ReturnOnError', false);
%% Close the text file. fclose(fileID); %% Create output variable time(:,i)=dataArray{1:size, 1}; P(:,i)=dataArray{1:size, 2}; needle(:, i)=dataArray{1:size, 3}; Pav=mean(P,2); nav=mean(needle,2); tav=mean(time,2); %% Clear temporary variables clearvars filename delimiter startRow formatSpec fileID dataArray ans; end
I get this error as I run the code to the exceptional set:
Unable to perform assignment because the size of the left side is 2500-by-1 and the size of the right side is 2909-by-1.
  4 commentaires
Bob Thompson
Bob Thompson le 12 Nov 2018
I would double check the size of each of those arrays, to make sure that you aren't accidently getting time, P, or needle to be 2909
Samy Alkhayat
Samy Alkhayat le 12 Nov 2018
Ok here is what the code does: It concatenates till the file no. 12/32 only because the file no 13 is of size longer than the previous 12.
So I get 500x12 for P and needle, 500x1 for Pav and needleav as the mean works only over 12 rathat than 32

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Debugging and Analysis dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by