Is there any way to:
a. provide two sets of geodist criteria
for a single query; or
b. chain queries together to do one
geodist query, then another based on
the results of the first one?
Alternatively, does anyone have any other suggestions on how to calculate the intersection of two geodis-based searches, as highlighted by the red area in the following image:
http://cl.ly/0v3m1L1P3U200l1P2C3d
Thanks.
You could set multiple GEODIST expression in same query. It finally looks like
mysql> SELECT *, GEODIST ( x1, y1, lat_attr, lon_attr ) as c1, GEODIST ( x2, y2, lat_attr, lon_attr ) as c2 FROM YOUR_INDEX where c1<blue_dist and c2<yellow_dist
or
mysql> SELECT *, GEODIST ( x1, y1, lat_attr, lon_attr ) as c1, GEODIST ( x2, y2, lat_attr, lon_attr ) as c2, c1<blue_dist and c2<yellow_dist as yellow_cond FROM YOUR_INDEX where yellow_cond=1
where x1, y1, x2, y2, blue_dist, red_dist are USER defined constants
Related
I want to find the intersect between 2 time vectors t1 and t5 which have some gaps marked by the stars as in the figure. Because intersect function in matlab just find exactly value so I have to use ismembertol. My result is the middle line, which is missing the gap information in the t5 vector. How can I achieve this? This is my code:
`
tol = 1e-08; Fs = 50;
[a,b] = ismembertol(t1,t5,tol);
tcom15 = t1(a);
t1gap = t1(find(round(diff(t1)* 86400*Fs)>1));
t5gap = t5(find(round(diff(t5)* 86400*Fs)>1));
tcom15gap = tcom15(find(round(diff(tcom15)* 86400*Fs)>1));
figure; plot(t1,2*ones(length(t1),1)); hold on
plot(t5,3*ones(length(t5),1));ylim([1 4])
plot(t1gap,2*ones(length(t1gap),1),':*','MarkerSize',5)
plot(t5gap,3*ones(length(t5gap),1),':*','MarkerSize',10)
plot(tcom15,2.5*ones(length(tcom15),1))
plot(tcom15gap,2.5*ones(length(tcom15gap),1),':*','MarkerSize',10)
I have an equation r that I want to take in values from Ex and Vt. Ex and Vt give multiple values when run, but r does not. I need r to give values for each number in x1 and xL1.
Thanks.
Es= 1.01911;
Vab= 1.6;
s= 75.5;
x1= [93.5, 93.1, 92.0, 91.9, 92.2];
xL1= [49.0, 46.2, 48.6, 46.3, 48.9];
Ex= x1*(Vab/100);
Vt= Es*(xL1/s);
r=(20*(Ex-Vt))/Vt
I think what you are after might be element-wise operation, i.e.,
r=(20*(Ex-Vt))./Vt
such that
r =
25.237 27.773 24.877 27.055 24.699
I'm having trouble plotting a set of complex numbers in maple.
I know what it should look like from a drawing I produced but I'd like to plot it in maple. My code is as follows;
z := x + I*y;
plots:-implicitplot([abs(z) <= 2, abs(z) >= 1, abs(arg(z)) >= Pi/4,
abs(arg(z)) <= Pi/2], x = -3...3, y = -3...3, filled = true);
The issue is that the inequalities are being plotted independently of each other rather than all together, so even the first pair of inequalities together fill the entire plane. Is there any way I can have the $4$ conditions imposed in $S$ be taken into account at the same time, rather than separately?
Didn't you mean for the second inequality to be reversed? Otherwise the first is redundant.
The command that you need is inequal, not implicitplot. Your args should be arguments. Your z expressions should be wrapped in evalc. (I don't why that's necessary, but it seems to be.) There's no need for filled= true. So, the command is
plots:-inequal(
[evalc(abs(z)) <= 2, evalc(abs(z)) >= 1,
evalc(abs(argument(z))) >= Pi/4, evalc(abs(argument(z))) <= Pi/2
], x = -3...3, y = -3...3
);
Sometimes using plots:-inequal takes a long time, in those cases I just use plots:-implicitplot with filledregions = true option. But I don't use a list of inequalities as its argument. For one plot only, implicitplot needs one equation/inequality, so what function can you use that gives you the intersection of regions for your inequalities? Very simple, just define a binary piecewise function with piecewise command. Here is how I do your plot.
f := piecewise( And( abs( x + y*I ) <= 2, abs( x + y*I ) >= 1, abs( argument( x + y*I ) ) >= Pi/4, abs( argument( x + y*I ) ) <= Pi/2 ), 1, 0 );
plots:-implicitplot( f > 1/2, x = -3..3, y = -3..3, filledregions = true, coloring = [yellow, white], view = [-3..3, -3..3] );
The output plot is the following.
Note that plots:-inequal gives a more accurate output, but plots:-implicitplot takes less time, so you should consider the trade-off between them and see which is better on your specific example.
I have this function in matlab-
function [c,arr2]=dist1(i,c,arr1,arr2,A,mx,point)
for j=i+1:mx
if arr1(i,j)==1 & A(j)~=0
x1=point(i,1);
y1=point(i,2);
x2=point(j,1);
y2=point(j,2);
d=((((x1-x2).^2)+((y1-y2).^2)).^(0.5));
if d< 0.5
arr2(c)=i;
c=c+1;
[c,arr2]=dist1(j,c,arr1,arr2,A,mx,point);
end
end
end
end
When I call this function this function I get following error-
Integers can only be raised to positive integral powers.
Error in dist1 (line 9)
d=((((x1-x2).^2)+((y1-y2).^2)).^(0.5));
This works fine if I remove power of 0.5 in the calculation of d.Why am I getting this error,there seems to be nothing wrong in this statement.Also I checked the values of x1,x2,y1,y2 in the preceding lines and they are
x1=208 y1=171 x2=207 y2=162
The error is pretty explicit:
Integers can only be raised to positive integral powers.
Your x1, x2, y1, y2 variables seem to be of an integer data type (such as uint8, int32, ...). They need to be double (or single) to perform that operation. So, try
d = double((((x1-x2).^2)+((y1-y2).^2)).^(0.5))^0.5;
Note also that, since x1, x2, y1, y2 are scalars, you could remove the dots:
d = double((((x1-x2)^2)+((y1-y2)^2))^0.5)^0.5;
Is there any function in Matlab like conv(u,v) but that sums up 'u(x)' and 'v(x)' instead of multiplying them?
Imagine:
u(x) = 66*(x-6)
v(x) = 6*(x-9)
Applying this "wanted function"...
sum = wantedfunction(u,v)
So,
sum(x) = 66*(x-6) + 6*(x-9)
Any ideas?
I believe you can do what you are asking for using anonymous functions:
u = #( x ) ( 66 * (x - 6) );
v = #( x ) ( 6 * (x - 9) );
w = #( x ) ( u(x) + v(x) );
This makes w the "sum" function you wanted - if I understood your question correctly.
Example: after I keyed in the above, I found
w(1:5)
Gave
-378 -306 -234 -162 -90
It's possible I completely missed the point of your question - if so, please leave a comment.
If by "conv" function you mean convolution then the equivalent of that for your case is simply adding two functions you want and then multiply them by delta(your desired spacing on x axis) and then sum over that, gives your function. Still you need to iterate this process by a "for" loop for different delays.