I am writing a script to deal with data output from a machine, I've attached a sample set. For columns A and B, the first column has 1-3 repeated and the second has the values measured. The data is effectively groups of three but with many data sets in the same column. (For example 2.03E+07, 7.41E+06, 1.51E+06 are the first set of three, 325000, 103000, 20300 are an independent set of three, etc. and the order matters. I hope that makes sense.)
My issue is that in some cases the value of 2 for example might be zero and the native software doesn't enter it as zero is just doesn't input it at all (like in columns E and F).
Is there a way to essentially say to Matlab that the first column should be 1-3 repeated so if one of the numbers is missing to input it in the first column and insert a zero in the second column? Effectively transformin columns E and F to I and J.
Sorry this is written in such a convoluted manner, I'm struggling to explain it well. Any other suggestions for getting around this problem are also welcome. Thanks

2 Comments

Jan
Jan on 22 Oct 2018
Edited: Jan on 22 Oct 2018
This is the contents of the Excel file - much easier to post it as text than to let the readers download and open it in Excel:
1 2.03E+07 1 2.03E+07
2 7.41E+06 3 1.51E+06
3 1.51E+06 2 103000
1 325000 3 20300
2 103000 1 196000
3 20300 2 57400
1 196000 3 15500
2 57400 1 211000
3 15500 2 60200
1 211000 3 14400
2 60200 1 172000
3 14400 2 56000
1 172000 3 13800
2 56000
3 13800
Now please explain, what "in some cases the value of 2 for example might be zero" means. Does the question concern the Excel file, so do you want to update the file? Or did you import the data already and the detail, that they come from an Excel file is not relevant?
The only reason I put it in Excel was I couldn't get the columns to space properly in the question input box. This works, cheers

Sign in to comment.

 Accepted Answer

Jan
Jan on 22 Oct 2018
Edited: Jan on 22 Oct 2018
I assume, that you can manage the Excel import or export by your own, this fills the missing values with zeros:
X = [1,3,2,3,1,2,3,1,2,3,1,2,3]
Y = [2.03E+07, 1.51E+06, 103000, 20300, 196000, 57400, 15500, 211000, ...
60200, 14400, 172000, 56000, 13800];
step = cumsum([false, diff(X)<0]) * 3;
Yfilled(step(end) + 3) = 0; % Care for a missing trailing 3
Yfilled(X + step) = Y;
Xfilled = repmat(1:3, 1, numel(Yfilled) / 3)
Of course if a complete set [1,2,3] is missing, this cannot be detected.

More Answers (0)

Products

Asked:

on 22 Oct 2018

Commented:

on 22 Oct 2018

Community Treasure Hunt

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

Start Hunting!