min

Subscript indices must either be real positive integers or logicals using min

陌路散爱 提交于 2019-11-28 10:22:02
问题 for control=1:7 name=strcat('tau: ', num2str(TD(control)),' PLD: ', num2str(PLD(control))); fprintf('Control: %i/7\n', control) Maps(control) = struct('GradOFF', [], 'GradON', []); for lin=1:size(data(subject).perf_w_off,1) fprintf('Lin: %i/64\n', lin); for col=1:size(data(subject).perf_w_off,2) [x1, fval, exitflag, output] = fminunc(...) Maps(control).GradOFF(lin,col) = abs(x1(2)); [x2, fval, exitflag, output] = fminunc(...) Maps(control).GradON(lin,col) = abs(x2(2)); end end min1 = min(min

PowerPivot DAX - Dynamic Ranking Per Group (Min Per Group)

ε祈祈猫儿з 提交于 2019-11-28 07:43:37
问题 I am searching for a method to utilize within Microsoft PowerPivot 2010 that will allow me to perform dynamic ranking that will automatically update the associated rank value based on filters and slicer values that are applied. Thusfar, all examples I have seen utilize the Calculate() DAX function that overrides existing filters within the PowerPivot table via the All() function which causes predefined filters that users may apply to be disregarded. To illustrate my requirements, please

Mathematically Find Max Value without Conditional Comparison

旧城冷巷雨未停 提交于 2019-11-28 06:54:04
----------Updated ------------ codymanix and moonshadow have been a big help thus far. I was able to solve my problem using the equations and instead of using right shift I divided by 29. Because with 32bits signed 2^31 = overflows to 29. Which works! Prototype in PHP $r = $x - (($x - $y) & (($x - $y) / (29))); Actual code for LEADS (you can only do one math function PER LINE!!! AHHHH!!!) DERIVDE1 = IMAGE1 - IMAGE2; DERIVED2 = DERIVED1 / 29; DERIVED3 = DERIVED1 AND DERIVED2; MAX = IMAGE1 - DERIVED3; ----------Original Question----------- I don't think this is quite possible with my application

AWK - find min value of each row with arbitrary size

我与影子孤独终老i 提交于 2019-11-28 06:31:30
问题 I have a file with the lines as: 5 3 6 4 2 3 5 1 4 3 2 6 5 8 .. I want to get the min on each line, so for example with the input given above, I should get: min of first line: 2 min of second line: 1 .. How can I use awk to do this for any arbitrary number of columns in each line? 回答1: If you don't mind the output using digits instead of words you can use this one liner: $ awk '{m=$1;for(i=1;i<=NF;i++)if($i<m)m=$i;print "min of line",NR": ",m}' file min of line 1: 2 min of line 2: 1 If you

MySQL - next / previous ID wih cycling

风格不统一 提交于 2019-11-28 06:05:53
问题 I need to create previous / next functionality with cycling. My current solution, If I select MAX(ID) gives next as NULL . How can I most efficiently get MIN(ID) instead of NULL (and vice versa for other direction). Of course, I can use IF or just create second query if my result is NULL , but I wonder if there is better solution. My table has three columns ex: ID foto like 3 A 0 4 B 0 5 C 0 10 D 0 If I select ID 4 next is 5, prev is 3 //this solution I have For ID 3, next is 4, previous is

Using min/max *within* an Integer Linear Program

為{幸葍}努か 提交于 2019-11-28 04:32:17
I'm trying to set up a linear program in which the objective function adds extra weight to the max out of the decision variables multiplied by their respective coefficients. With this in mind, is there a way to use min or max operators within the objective function of a linear program? Example: Minimize (c1 * x1) + (c2 * x2) + (c3 * x3) + (c4 * max(c1*x1, c2*x2, c3*x3)) subject to #some arbitrary integer constraints: x1 >= ... x1 + 2*x2 <= ... x3 >= ... x1 + x3 == ... Note that (c4 * max(c1*x1, c2*x2, c3*x3)) is the "extra weight" term that I'm concerned about. We let c4 denote the "extra

Find min/max in a two dimensional array

放肆的年华 提交于 2019-11-28 02:03:27
I have an array with the following format: Array ( [0] => Array ( [DateTime] => "2013-05-22 14:21:01" [Price] => 102.01 ) [1] => Array ( [DateTime] => "2013-05-23 15:55:01" [Price] => 52.60 ) [2] => Array ( [DateTime] => "2013-05-25 14:23:01" [Price] => 452.25 ) ... etc ) I need to discover the lowest and highest value of Price . min only returns they key. I've also tried max(array_map("max", $data)) but that only returns 452.25 . Will I have to use a foreach and do it manually? Here's one way to get the min and max values: $min = min(array_column($array, 'Price')); $max = max(array_column(

Java - limit number between min and max

ⅰ亾dé卋堺 提交于 2019-11-28 00:37:45
I want to return the number as long as it falls within a limit, else return the maximum or minimum value of the limit. I can do this with a combination of Math.min and Math.max . public int limit(int value) { return Math.max(0, Math.min(value, 10)); } I'm wondering if there's an existing limit or range function I'm overlooking. 3rd party libraries welcome if they are pretty common (eg: Commons or Guava) As of version 21, Guava includes Ints.constrainToRange() (and equivalent methods for the other primitives). From the release notes : added constrainToRange([type] value, [type] min, [type] max)

Correct implementation of min

南笙酒味 提交于 2019-11-27 21:20:10
At time 0:43:15 in this Tech-Talk about D , The implementation of the min function is discussed. Concerns about "stability" and "extra shuffling (if values are equal)" when being used in some algorithm(s) is proposed as one of the reasons for the implementation shown. Can anyone provide a real/practical use-case (or provide a more detailed explanation) where this specific implementation of min is "stable" (aka better) as opposed to its other possible implementation? Or is this just another example of alpha-geeks going a bit too far? Recommended implementation: template <class LHS, class RHS,

Find the smallest amongst 3 numbers in C++ [duplicate]

廉价感情. 提交于 2019-11-27 20:43:28
问题 This question already has answers here : Simple logic problem: Finding largest and smallest number among 3 numbers (5 answers) Closed 3 years ago . Is there any way to make this function more elegant? I'm new to C++, I don't know if there is a more standardized way to do this. Can this be turned into a loop so the number of variables isn't restricted as with my code? float smallest(int x, int y, int z) { int smallest = 99999; if (x < smallest) smallest=x; if (y < smallest) smallest=y; if(z <