INTRODUCTION: Hi, I have multiple arrays i.txt made of two columns and n-rows in a folder. The examples below display the first two arrays:
% 1.txtfid =fopen('C:\Users\EMERSON\Desktop\ARRAYS\1.txt');A1=textscan(fid,'%f %f');fclose(fid);% 3 130% 4 340% 5 159% 6 030% 7 100% 2.txtfid =fopen('C:\Users\EMERSON\Desktop\ARRAYS\2.txt');A2=textscan(fid,'%f %f');fclose(fid);% 10 125% 11 300% 12 110
GOAL: I want to construct a matrix M with elements of the second column of i.txt as below:
1 2 3 4 5 6 7 8 9 10 11 12 13NaN NaN 130 340 159 030 100 NaN NaN NaN NaN NaN NaNNaN NaN NaN NaN NaN NaN NaN NaN NaN 125 300 110 NaN
A value is assigned for each column of M (First row of M above, but it will not appear later, I display here only for clarification).
Then I import the array 1.txt. If the first column of the array 1.txt contains a value assigned in M, then I extract the corresponding value from the second column of 1.txt and write in the cell of the matrix designed for it (first row and j-column).
And I write NaN (not available) in the cells of M for which the value is not found in i.txt.
Then I import the array 2.txt and do the same in the second row of the matrix, and so on for i.txt arrays. The resulting matrix will contain i-rows and j-columns, where j is the range of values pre-assigned.
I wonder if someone could help me how to write the commands that does this extraction and write in the proper place of the matrix.
Thank you in advance for your help