MATLAB Answers

How to arrange random data in a order of sequence?

8 views (last 30 days)
Manoj
Manoj on 13 Sep 2020
Commented: Rena Berman on 9 Oct 2020 at 16:34
PFA.. of the data (rawdata.txt) which is in random order for the Long, Lat, U and V parameters
Need the output in the same way as given in attachment. Pls find
Thankin you

  2 Comments

Rik
Rik on 14 Sep 2020
Unfortunately for Manoj, their attempt at cheating was foiled by Google cache (permalink, should be available in a few hours):
PFA.. of the data (rawdata.txt) which is in random order for the Long, Lat, U and V parameters
Need the output in the same way as given in attachment. Pls find
Thankin you

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 13 Sep 2020
[sortedData, sortidx] = sortrows(YourData, [-2, 1]);
sortedU = U(sortidx, :);
sortedV = V(sortidx, :);

  3 Comments

Manoj
Manoj on 14 Sep 2020
Mr. Rik
Actually there was a fault in the attachment rawdata.txt. Hence I removed from this post.
I rectified the fault and modified.
Again, I posted here with the new query for the same work. pls check
Problem statement
PFA of two matrices of different sizes
one is of size 185X1 showing starting value 77 to ending value 100 with a increment of 0.125
Another one of size 241X1 showing staring value 30 to ending value 0 with a decrement of 0.125
Now I need to assign the each single value from the matrix of size (241X1) to the another matrix of size (185X1).
For example
i.e first value 30 in the matrix (241X1) will assign to the matrix of size (185X1) i.e from 77 to 100
second value 29.875 in the matrix (241X1) will assign to the same size of matrix (185X1) i.e from 77 to 100.
Third value 29.75 in the matrix (241X1) will assine again to the same size of matrix (185X1) i.e from 77 to 100.
..............
..............
.............. and so on to end value 0 of the 241X1 matrix
I need the output in a way which is given below.. pls find
77 30
77.125 30
77.25 30
77.375 30
77.5 30
77.625 30
77.75 30
77.875 30
78 30
78.125 30
78.25 30
78.375 30
78.5 30
78.625 30
78.75 30
-- 30
-- 30
-- 30
-- 30
-- 30
-- 30
so on 30
-- 30
-- 30
100 30
-- --
77 29.875
77.125 29.875
77.25 29.875
77.375 29.875
77.5 29.875
77.625 29.875
77.75 29.875
77.875 29.875
78 29.875
78.125 29.875
78.25 29.875
78.375 29.875
78.5 29.875
78.625 29.875
78.75 29.875
-- 29.875
-- 29.875
-- 29.875
-- 29.875
-- 29.875
-- 29.875
so on 29.875
-- 29.875
-- 29.875
100 29.875
-- --
77 29.75
77.125 29.75
77.25 29.75
77.375 29.75
77.5 29.75
77.625 29.75
77.75 29.75
77.875 29.75
78 29.75
78.125 29.75
78.25 29.75
78.375 29.75
78.5 29.75
78.625 29.75
78.75 29.75
-- 29.75
-- 29.75
-- 29.75
-- 29.75
-- 29.75
-- 29.75
so on 29.75
-- 29.75
-- 29.75
100 29.75
Thank you
Walter Roberson
Walter Roberson on 14 Sep 2020
[t1, t2] = ndgrid(vector241, vector185);
output = [t1(:), t2(:)];
Manoj
Manoj on 14 Sep 2020
Thank you very much Mr.W.Roberson sir..
You are the MVP in this community when compare with others
Thank you once again

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!