本文介绍了删除非唯一值并重新排列向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了Sloan Digital Sky Survey(SDSS)数据,得到的最终数据产品为文件.第一列是wLength(波形长度),第二列是flux.

I worked with Sloan Digital Sky Survey (SDSS) data, and got a final data product of this file. The first column is of wLength (wavlength) and second is of flux.

将零存储在zero_F变量zero_F = find(a==0)中,我使用wLength(zero_F)=[];flux(zero_F)=[];从两个列中将其删除.我想绘制wLengthfluxflux取决于wLength,但是wLength包含非唯一值.

Storing the zeros in zero_F variable zero_F = find(a==0), I removed them from both columns using wLength(zero_F)=[]; and flux(zero_F)=[];. I want to plot wLength vs flux, flux is dependent on wLength but wLength contains values which are non-unique.

如何获取数据中非唯一值的索引,以便可以从wLengthflux中删除相应的索引,以使大小相同的数组并绘制它们.另外,由于issorted(wLength)返回了0,这意味着未对wLength进行排序,但是将其排序肯定会更改其与flux的值的对应关系,我如何基于以下内容对flux进行排序wLength值.

How can I get indices of non-unique values in data so that I can remove the corresponding indices from both wLength and flux to make the arrays of same size and plot them. Also, since issorted(wLength) returned 0 that'd mean that wLength isn't sorted out, but sorting it out will definitely change the correspondence of it's values with flux, how can I sort flux based on wLength values.

我了解了有关xy排序的信息此处此处但是我没有得到答案.

I read about sorting x vs y here and here but I quite didn't get the answers.

推荐答案

您可以尝试以下方法:

% Get unique values from wLength
[wLengthUn, iUn, ~] = unique(wLength);
fluxUn = flux(iUn);

% Sort the arrays, if needed
[wLengthSrt, iSrt] = sort(wLengthUn);
fluxSrt = fluxUn(iSrt);

% Plot data
plot(fluxSrt, wLengthSrt)

这篇关于删除非唯一值并重新排列向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:10