This may be a silly question but if I have a long list (let's call it data
)such as this:
How can I make that list of a certain lenght?. In particular I want to subtract the entire list with a part of the same list but since they are of different length I cannot do it.
I would like to do something like this:
data-Select[data, 50 <= #[[1]] <= 105 &]
but since data
is of higher lenght than Select[data, 50 <= #[[1]] <= 105 &]
it gives me an error. Is there a way around this?
Thank you.
EDIT:
I have been trying to do it with Interpolation
like this:
dat1 = Select[data, 60 <= First[#] <= 140 &];
dat2 = Select[data, 10 <= First[#] <= 65 &];
fit1 = Interpolation[dat1];
fit2 = Interpolation[dat2];
fit1[#] - fit2[#] &;
but doing it with interpolation in this way is not working for me either perhaps because the interpolations are of different sizes as well?.
ConstantArray
which is the length of the list you’re pulling from, but this seems like there will be a sequence that is found, and the operation of subtracting part of the list from the whole list honestly does not make any sense to me. Maybe I am misinterpreting, but how would the elements be distributed? This does not seem standard hence my requests for clarification. $\endgroup$data[[;; ;; 50]]
to get essentially the same that you will get fromdata
(taking every 50 points or so) and at the same time reducing the lenght ofdata
resulting in a lenght of 58 in this case. I just hoping to find something similar in which I can reduce the lenght of data such as I can subtract some other part of the same data. I hope that makes more sense. $\endgroup$data-part of data (from the interpolation)
. $\endgroup$Range[10]
and you want to subtract {7, 8, 9} from the entire list, what do you expect to happen—that is, what is your expected output? Please note that the word subtract is not the same as remove. $\endgroup$data[[;; ;; 50]]]
(which reduces the lenght ofdata
while more of less keeping the overall trend of the data) and also my example of perhaps fitting the entire data and then there should be a way to subtract a part of the fitting ofdata
with the entire fitting ofdata
, no? $\endgroup$