Reduce discretisation in matrix

16 ビュー (過去 30 日間)
Jean
Jean 2015 年 1 月 3 日
コメント済み: Star Strider 2015 年 1 月 4 日
Hello everybody.
I need your help. I have a matrix representing 200000 points. x, y and z coordinates and a pressure value for each point. I manage to vizualise my points with a colorbar for pressure values using plot3c ( from Uli Theune, University of Alberta) but the generated figure is too heavy and my computer crashes. I would like to reduce the number of points and have less pressure values? I would like to plot the same figure but "pixelized". I hope I make mylself clear. If you need some extra info please don't hesitate.
Thank you!
  4 件のコメント
per isakson
per isakson 2015 年 1 月 3 日
Jean
Jean 2015 年 1 月 3 日
編集済み: Jean 2015 年 1 月 3 日
Thanks per isakson; I tried to use pcolor but I don't understand how to use it in y case. Could you give me an example please?

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2015 年 1 月 3 日
That is actually easier than I thought it would be. If you want to take every 4th row for instance:
decmat = matrix(1:4:end, :);
or with an example:
X = repmat(1:25, 4, 1)';
Xdec = X(1:4:end,:);
Your ‘decimated’ matrix ‘decmat’ or ‘Xd’ is now ¼ the size of your original matrix. You can choose different intervals or even random rows to put into your ‘decimated’ matrix.
Is this what you want to do?
  2 件のコメント
Jean
Jean 2015 年 1 月 3 日
編集済み: Jean 2015 年 1 月 3 日
This is good but not exactly what I am looking for. In this case I just suppress a row every n rows. But I am not doing any kind of average isn't it? I am looking for something that will read the values on 5 adjacent rows and calculate the average for those 5 values and make a new row.
Star Strider
Star Strider 2015 年 1 月 4 日
You may have to experiment with this with your data, but in this simulation at least, it works and should give you the means of every 5 rows in the ‘Xm’ matrix:
X = repmat(1:30, 4, 1)'; % Created Simulated Data Matrix
Xs = reshape(X, 5, [], 4) % Reshape To Allow Mean Calculations
Xp = permute(Xs, [1 3 2]) % ‘Transpose’ 3D MAtrix
Xm = squeeze(mean(Xs,1)) % Calculate Means

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by