vector3d random sample

2 ビュー (過去 30 日間)
Rick Verberne
Rick Verberne 2020 年 6 月 18 日
コメント済み: Rick Verberne 2020 年 6 月 19 日
Hi all,
I have a problem plotting some data. There are too many points and therefore I want to plot a random sample.
The class is vector3d and contains 13717 points. I would be interested in plotting around a 1000 points or just a certain percentage. However, I keep getting the following error:
'Error using reshape
Product of known dimensions, 3, not divisible into total number of elements, 13717.'
Hope anyone here can help me.
Cheers,
Rick

回答 (2 件)

KSSV
KSSV 2020 年 6 月 18 日
編集済み: KSSV 2020 年 6 月 18 日
n = 13717 ; % totalpoints
m = 1000 ; % points to select
x = rand(n,1) ; y = rand(n,1) ; % random data for demo
idx = randperm(n,m) ; % select m points outof n randomly
plot(x(idx),y(idx),'*r') % plot the points selected
  3 件のコメント
KSSV
KSSV 2020 年 6 月 18 日
Why it din't work? It selects m random points out of n. What did work for you?
Rick Verberne
Rick Verberne 2020 年 6 月 19 日
I think because of the structure of that class, or maybe I just did something wrong. The toolbox allows for sampling when you first load your data. So I created a second dataset. I can use the more detailed information for creating images and calculations on boundaries and use the reduced set for some plots where plotting everything just convolutes the data.

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


Ameer Hamza
Ameer Hamza 2020 年 6 月 18 日
編集済み: Ameer Hamza 2020 年 6 月 18 日
vector3d is not a MATLAB class. In case you have data points in the form of n*3 matrix. You can do something like this
M = rand(13717, 3); % for example
idx = randperm(size(M,1), 1000); % select 1000 points from 13717
M_small = M(idx, :); % 1000x3 matrix
  3 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 6 月 18 日
So do you have a custom class vector3d?
Rick Verberne
Rick Verberne 2020 年 6 月 19 日
Yes, or at least the person who wrote it. It is a program called MTEX

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

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by