range

How can I find the maximum values in each range of a list in Mathematica?

时光毁灭记忆、已成空白 提交于 2019-12-12 04:37:27
问题 I can do this in MATLAB easily but I'm trying to do it Mathematica. I have a 27000 element (15 minutes*30 measurements per second) list of wind speed values. I want to find the max value in each 2700 element (90 second) range and output it to a vector. Here is the MATLAB code: N = length(AlongWS); SegTime = 90; NSeg = (N/30)/90; Max90 = zeros(NSeg,1); Incr = N/NSeg; for i = 1:NSeg Max90(i,1) = max(AlongWS((i-1)*Incr+1:(i*Incr),1)); end Here is what I've typed in Mathematica: N = Length

Jquery UI Range - Add Plus symbol

余生颓废 提交于 2019-12-12 04:26:10
问题 Im currently building a project planner form for a client, i Am using Jquery UI for a range slider. I am struggling to figure out how to make it so that when the range value is at Max, it adds a Plus(+) to after the value in the input field. My current script is function projectPlannerSlider() { $("#budgetSlider").slider({ range: "min", min: 100, max: 25000, value: 7000, slide: function (event, ui) { $(".budget").val("\u00A3" + ui.value); } }); $(".budget").val("\u00A3" + $("#budgetSlider")

How can a numpy.ufunc.reduceat indices be generated from Python Slice Object

﹥>﹥吖頭↗ 提交于 2019-12-12 04:21:55
问题 Say I have a slice like x[p:-q:n] or x[::n] I want to use this to generate the index to be passed into numpy.ufunc.reduceat(x, [p, p + n, p + 2 * n, ...]) or numpy.ufunc.reduceat(x, [0, n, 2 * n, ...]) . What is the easiest and efficient way to get it done? 回答1: Building on the comments: In [351]: x=np.arange(100) In [352]: np.r_[0:100:10] Out[352]: array([ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90]) In [353]: np.add.reduceat(x,np.r_[0:100:10]) Out[353]: array([ 45, 145, 245, 345, 445, 545, 645,

How to toggle a specific class set

天大地大妈咪最大 提交于 2019-12-12 03:56:09
问题 I have a range of classes: classA classB classC and I have a <span class='fixedClass'> which needs to be toggled between one of these classes depending on a specific condition. You might say to use jQuery toggleClass However my span has already other class attached to it which needs to stay always. What's fastest and shortest code in jQuery to do this? 回答1: This sample may help you: http://jsfiddle.net/e9bj5/ $(function(){ $('.fixedClass').on("click", function() { var box = $(this); if ( box

Algorithm for Intersection (or Merge) of Numerical Ranges

╄→гoц情女王★ 提交于 2019-12-12 03:54:02
问题 Let's say I have a list of ranges like this: List A) 0 to 3, 9 to 14 List B) 1 to 4, 6 to 7, 14 to 16 List C) 15 (i.e., 15 to 15) I'd like to get a merged list of these ranges where the result would look like this: Merged Result List) 0 to 4, 6 to 7, 9 to 16 (notice that the result is a merging/intersection/union of Lists A, B, and C) I'm sure there's an algorithm for this, but have no idea. Has anyone come across this before? (pseudocode, or VB, would be great) Adding a visual representation

Highstock: how programmatically sum selected values and show the sum to user

北城余情 提交于 2019-12-12 03:46:00
问题 How Can I sum the points in a line within a selected range in order to be shown to users? 回答1: Yes it is possible, by means of using afterSetExtremes function (http://api.highcharts.com/highstock#xAxis.events.afterSetExtremes) which allows to catch "change" range event and run custom function. So then you can interate for all points in serie and limit which of them should be added to sum, by check min/max range value. http://jsfiddle.net/2WdQw/ afterSetExtremes: function(e) { var sum = 0,

Change range withouth scaling in matplot

柔情痞子 提交于 2019-12-12 03:27:45
问题 I have a question, I am making a program that displays a zoomed area of Peru but the axis shown are in the range of the image (e.g. 7000x7500) but i want to be in UTM range (e.g. x-axis between 500000-600000 and y-axis 9500000-9700000) I have tried using plt.set_xlim and plt.sety_lim but no success, I think I have to use plt.autoscale(False) but it also didn't work or I used it wrong. I create the figure and axes out of the main program f = plt.figure(figsize=(5,5)) axe = f.add_axes([0, 0, 1,

Double Conditioned selection of data in r

只谈情不闲聊 提交于 2019-12-12 02:58:29
问题 I read extensively about selection with condition using function like aggregate or the package pylr but seems ok for my case. I am sure is not difficult to program, but I would like some input. Basically how to start, what's the line of reasoning that you would follow. Thanks for any advice. So my simplified dataset looks like this time.stamp <- c(21.0,21.1,21.2,21.3,21.4) behavior <- c("close", "1", "close","1","close") event_type <- c("start","point","stop","point","start") example <- data

Finding Touched elments CKEDITOR

隐身守侯 提交于 2019-12-12 02:55:09
问题 I am looking several days now on the web, but i can't seem to find out, how i can find if the caret is touching a element. Let me explain myself a little better with this example. This is a[ ] <span>example</span> As Example we say that the caret is the tag [ ]. And now we like to know if the caret is near a span element? How can we find this? Also I need to know if the span element is before or after the caret. I'm doing this with the CKEDITOR 4.0 api.. 回答1: Try this: var range = CKEDITOR

Library for handling a List of Ranges

孤者浪人 提交于 2019-12-12 02:50:05
问题 I have to handle a list of timestamps ( Long ) in a Java 8 application: If a user adds a new range, it should be merged together with the other existing ranges, like in this pseudo code: rangeList = [100, 200], [300, 400], [500, 600], [700, 800] newRangeList = rangeList.add([150, 550]) println(newRangeList) // Expected output: [100, 600], [700, 800] I tried using a List of Google Guava Range class but merging together new timestamp ranges gets surprisingly complicated. Using the new