问题描述
我使用了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)=[];
从两个列中将其删除.我想绘制wLength
与flux
,flux
取决于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.
如何获取数据中非唯一值的索引,以便可以从wLength
和flux
中删除相应的索引,以使大小相同的数组并绘制它们.另外,由于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.
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)
这篇关于删除非唯一值并重新排列向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!