How to calculate winddirection from degrees? - math

I'm reading (JSON) weatherdata into a small delphi-application. The winddirection is represented by a floatvalue from 0-360. What i want is to calculate this value into 8 directions (N,NE,E,NW,S,SE,W,SW) on the compass and show them on my applicationform as a arrowsymbol. I can use a lot of if..then to solve this, but it would be much cleaner code to just calculate it. My mathematical skills is not what they used to be, so i hope some of you coluld help me? Thanks.

Not deplhi but perhaps something like this?
winds=["N","NE","E","SE","S","SW","W","NW","N"]
wind_={WIND_IN_DEGREES}
index=int(round(wind_/45,0))
print(winds[index])

Related

Write a loop to divide last value in y and first value in x and so on for #whole vector

I'm unsure how to do this. If possible a walkthrough on this would be greatly appreciated! Just started a class that uses R and find somethings to be very complicated.
Thanks!
I have tried to just write simple types of loops but not sure how to tie in all of the functions I need to do.

Simple function cant be plotted

enter image description here
I'm inexperienced because it's my first time learning it. I really appreciate your help.
The problem are missing brackets in the second line. It is
plt.plot(x, 3+math.exp-x*math.sin(6*x))
while it probably should be
plt.plot(x, 3+math.exp(-x)*math.sin(6*x))
The error could help you with this as you tried to substract x (an integer) from math.exp (a builtin_function_or_method)

Having some troubles understanding this code

The image of the code
What does the 5 highlighted lines of the code mean?
Basically to get the "get_top_covariances", I need to follow these 4 steps.
Start by finding the covariance matrix
The target feature should not be included in the outputs.
It may be easiest to solve this if you find the relevant_indices first, and then use relevant_indices to calculate highest_covariances.
You want to sort by absolute value but return the actual values.
Hence, I would highlight appreciate it if anyone could help to explain those 5 lines,as in what's it is trying to do.
By the way, what's that top_n for? I'm quite lost at this part.

Maxima: equations: eliminate variable inside diff() expression

I have this code:
(%i3)depends([y,x],t)$
eqsp: [y=2*x,
v=diff(y,t,1)+y];
eliminate(eqsp,[y]);
(eqsp) [y=2*x,v='diff(y,t,1)+y]
(%o3) [-'diff(y,t,1)-2*x+v]
And this is a picture for better visualization:
PNG of code in wxMaxima
I was expecting that Maxima would perform a substitution of "y" in the second equation, and then differentiate to get "[-2*diff(x,t,1)-2*x+v]".
This is of course not the real problem (which has many more equations), it's just that I think I'm missing some concept here for Maxima to do what I want.
Thanks in advance for your comments. I'm a newbie in Stackoverflow and in Maxima, sorry if I made some mistake.

Expressing set of sequences as one sequence

This is a discrete math problem, and i was hoping that someone will guide me in the right direction on how to go about solving it...
I have the following set of sequences:
a_(2n) = 8^n
This will give me the values of all the even terms
a_(2n+1) = (-3)8^n
This will give me the values of all the odd terms
I would like to know if there's a way for me to express the values of all terms (both even and odd) using only one formula! Would you please help me!
Thank you,
You can define it as follows:
a_k=[-1+2*(-1)^k]*8^(floor(k/2))

Resources