I have adapted the following code from Gnuplot 3d time animation from data file
filedata = 'Sun_t_v_state.dat'
filedata2 = 'Mercury_v_state.dat'
filedata3 = 'Venus_t_v_state.dat'
filedata4 = 'Earth_t_v_state.dat'
filedata5 = 'Mars_t_v_state.dat'
filedata6 = 'Jupiter_t_v_state.dat'
filedata7 = 'Saturn_t_v_state.dat'
filedata8 = 'Uranus_t_v_state.dat'
filedata9 = 'Neptune_t_v_state.dat'
filedata10 = 'Pluto_t_v_state.dat'
n = 44
set term gif animate
set output 'output.gif'
do for [j=1:n] {
set title 'time '.j
splot filedata u 2:3:4 every ::1::j w l lw 2, \
filedata u 2:3:4 every ::j::j w p pt 7 ps 2
splot filedata2 u 2:3:4 every ::1::j w l lw 2, \
filedata2 u 2:3:4 every ::j::j w p pt 7 ps 2
splot filedata3 u 2:3:4 every ::1::j w l lw 2, \
filedata3 u 2:3:4 every ::j::j w p pt 7 ps 2
splot filedata4 u 2:3:4 every ::1::j w l lw 2, \
filedata4 u 2:3:4 every ::j::j w p pt 7 ps 2
splot filedata5 u 2:3:4 every ::1::j w l lw 2, \
filedata5 u 2:3:4 every ::j::j w p pt 7 ps 2
splot filedata6 u 2:3:4 every ::1::j w l lw 2, \
filedata6 u 2:3:4 every ::j::j w p pt 7 ps 2
splot filedata7 u 2:3:4 every ::1::j w l lw 2, \
filedata7 u 2:3:4 every ::j::j w p pt 7 ps 2
splot filedata8 u 2:3:4 every ::1::j w l lw 2, \
filedata8 u 2:3:4 every ::j::j w p pt 7 ps 2
splot filedata9 u 2:3:4 every ::1::j w l lw 2, \
filedata9 u 2:3:4 every ::j::j w p pt 7 ps 2
splot filedata10 u 2:3:4 every ::1::j w l lw 2, \
filedata10 u 2:3:4 every ::j::j w p pt 7 ps 2
}
But when I run this I only get one frame in the gif file, labeled 'time 1'; what do I need to change to get this to work?
I needed to switch it to all within one splot command like so:
# define fixed axis-ranges
# filename and n=number of lines of your data
filedata = 'Sun_t_v_state.dat'
filedata2 = 'Mercury_v_state.dat'
filedata3 = 'Venus_t_v_state.dat'
filedata4 = 'Earth_t_v_state.dat'
filedata5 = 'Mars_t_v_state.dat'
filedata6 = 'Jupiter_t_v_state.dat'
filedata7 = 'Saturn_t_v_state.dat'
filedata8 = 'Uranus_t_v_state.dat'
filedata9 = 'Neptune_t_v_state.dat'
filedata10 = 'Pluto_t_v_state.dat'
n = 44
set term gif animate
set output 'output.gif'
do for [j=1:n] {
set title 'time '.j
splot filedata u 2:3:4 every ::1::j w l lw 2, \
filedata u 2:3:4 every ::j::j w p pt 7 ps 2, \
filedata2 u 2:3:4 every ::1::j w l lw 2, \
filedata2 u 2:3:4 every ::j::j w p pt 7 ps 2, \
filedata3 u 2:3:4 every ::1::j w l lw 2, \
filedata3 u 2:3:4 every ::j::j w p pt 7 ps 2, \
filedata4 u 2:3:4 every ::1::j w l lw 2, \
filedata4 u 2:3:4 every ::j::j w p pt 7 ps 2, \
filedata5 u 2:3:4 every ::1::j w l lw 2, \
filedata5 u 2:3:4 every ::j::j w p pt 7 ps 2, \
filedata6 u 2:3:4 every ::1::j w l lw 2, \
filedata6 u 2:3:4 every ::j::j w p pt 7 ps 2, \
filedata7 u 2:3:4 every ::1::j w l lw 2, \
filedata7 u 2:3:4 every ::j::j w p pt 7 ps 2, \
filedata8 u 2:3:4 every ::1::j w l lw 2, \
filedata8 u 2:3:4 every ::j::j w p pt 7 ps 2, \
filedata9 u 2:3:4 every ::1::j w l lw 2, \
filedata9 u 2:3:4 every ::j::j w p pt 7 ps 2, \
filedata10 u 2:3:4 every ::1::j w l lw 2, \
filedata10 u 2:3:4 every ::j::j w p pt 7 ps 2
}
Related
I would like to write a matlab code to calculate the value of a function of two variables g(i,j) = i + j + 1 for every pair (i,j) in the set MV = {(1,3), (2,4), (5,6), (5,4), (7,2)} so that the output results in g = {5, 7, 12, 10, 9} based on the following algorithm:
Step 0. MV_0 = empty set;
Step 1. h=1;
Step 2. while MV_h ~= empty set {
Step 3. for every (i,j) in MV {
Step 4. g(i,j)
Step 5. }
Step 6. h=h++
Step 7. }
So far I have tried the following, but I couldn't figure it out. Please any hint/assistance. Thanks in advance!
MV = {}; % Step 0
h = 1; % Step 1
% MV= intersect(r(r==1),s(s==3))
while isempty(MV{h})==0 % MV{h} is nonempty from Step 2
MV = {[1,3], [2,4], [5,6], [5,4], [7,2]}
% Step 3, for every (i,j) in EMV{h}
for i=1:length(MV)
for j = 1:length(MV)
MV{h} = g(i,j); % Step 4
end
end
h = h+1; % Step 6
end
g % to get the final result g = {5, 7, 12, 10, 9}
% subfunction
function y = g(i,j)
y = i+j+1;
end
I guess u need the following:
function Camp()
clear,clc
MV = {};
h = 1;
while isempty(MV)
MV = {[1,3], [2,4], [5,6], [5,4], [6,2]};
for m = 1:length(MV)
i = MV{m}(1);
j = MV{m}(2);
MV{h} = g(i,j)
h = h+1;
end
end
end
% sub function
function y = g(i,j)
y = i+j+1;
end
Output is:
MV =
Columns 1 through 3
[5] [7] [12]
Columns 4 through 5
[10] [9]
Here's what I did. It's just about a reminder for a friend to be able to take his drugs on time.
import time
from win10toast import ToastNotifier
notify = ToastNotifier()
CurrentTime = 0
IconPath = "C:\\Users\\Hash\\Downloads\\Pill0.ico"
def alert(AlertHour, AlertMinute, AlertMessage):
while True:
CurrentTime = time.time()
CurrentHour = CurrentTime // 3600 % 24
CurrentMinu = CurrentTime // 60 % 60
if (CurrentHour == AlertHour and CurrentMinu == AlertMinute):
notify.show_toast("Drop Time!", AlertMessage, duration=120, icon_path=IconPath)
alert(21, 30, ">>>> E P I C I P R I N 5ML <<<<")
alert(17, 48, ">>>> seccE P I C I P R I N 5ML <<<<")
alert(9, 15, ">>>> P A T A N O L <<<<")
alert(21, 15, ">>>> P A T A N O L <<<<")
alert(9, 32, ">>>> E P I C I P R I N 5ML <<<<")
alert(15, 32, ">>>> E P I C I P R I N 5ML <<<<")
alert(21, 32, ">>>> E P I C I P R I N 5ML <<<<")
alert(3, 32, ">>>> E P I C I P R I N 5ML <<<<")
alert(9, 50, ">>>> E P I F E N A C <<<<")
alert(17, 50, ">>>> E P I F E N A C <<<<")
alert(1, 50, ">>>> E P I F E N A C <<<<")
alert(22, 00, ">>>> E P I C I P R I N 5G <<<<")
But it only runs the first alert method ignoring the rest even if their conditions are met.
Right now I'm stranded.
Any help please?
Thank you.
Well, once you run the first function, it gets into an infinite loop, therefore the python interpreter never gets to run the other calls. What you want to look into is threading. In a nutshell, threading allows you to run multiple processes simultaneously. Look into it
here
Solve[{A + B = 3, 2 A + B = 5}, {A, B}]
evaluates to A = 2, B = 1.
How can I Print the result like this
W = 2 + 1 * Sinx
Study https://reference.wolfram.com/language/ref/ReplaceAll.html and then try
Print[W==A+B*Sinx/.Solve[{A+B==3, 2A+B==5}, {A,B}][[1]]]
which prints
W==2+Sinx
because Mathematica automatically simplifies 1*Sinx to Sinx
I want to do a simple thing:
M: matrix([a,b], [c,d]);
N: matrix([1,2], [3,4]);
solve(M = N, [a,b,c,d]);
but I get the result []. If I break the above into many constraints, like this:
M: matrix([a,b], [c,d]);
N: matrix([1,2],[3,4]);
c1: M[1,1] = N[1,1];
c2: M[1,2] = N[1,2];
c3: M[2,1] = N[2,1];
c4: M[2,2] = N[2,2];
solve([c1, c2, c3, c4], [M[1,1], M[1,2], M[2,1], M[2,2]]);
I get a good result [[a=1,b=2,c=3,d=4]]. But this method would be painful for big matrices. Is there some easier way to do this?
Converting matrixes to list can help
(%i1) M: matrix([a,b], [c,d])$
(%i2) N: matrix([1,2] [c,d])$
(%i3) f(M):= apply(join, args(M))$
(%i4) e: map("=", f(M), f(N));
(%o4) [a = 1, c = 3, b = 2, d = 4]
(%i5) solve(e, [a, b, c, d]);
(%o4) [a = 1, c = 3, b = 2, d = 4]
I failed my algorithm exam in January. I'm going to an oral exam tomorrow. I was going through the ordinary exam and answers, when there was an answer I couldn't understand.
According to the answers, the answer is A. Why? 20 mod 7 is 6, but 12 mod 7 is 5 and it is empty. Hope that you would help me out here.
PS: Sorry if the formatting is wrong
h(20,0) = 5
h(12,0) = 3
h(5,0) = 3*
h(5,1) = 6
h(3,0) = 6*
h(3,1) = 2
h(1,0) = 2*
h(1,1) = 5*
h(1,2) = 0
* collision
i k
-------------------------
0 20 (2*20+3*0^2) mod 7 = (40 + 0) mod 7 = 40 mod 7 = 5 <- [e, e, e, e, e, 20, e]
0 12 (2*12+3*0^2) mod 7 = (24 + 0) mod 7 = 24 mod 7 = 3 <- [e, e, e, 12, e, 20, e]
0 5 (2*5+3*0^2) mod 7 = (10 + 0) mod 7 = 10 mod 7 = 3 <- collision
1 5 (2*5+3*1^2) mod 7 = (10 + 3) mod 7 = 13 mod 7 = 6 <- [e, e, e, 12, e, 20, 5]
0 3 (2*3+3*0^2) mod 7 = (6 + 0 ) mod 7 = 6 mod 7 = 6 <- collision
1 3 (2*3+3*1^2) mod 7 = (6 + 3) mod 7 = 9 mod 7 = 2 <- [e, e, 3, 12, e, 20, 5]
0 1 (2*1+3*0^2) mod 7 = (2 + 0) mod 7 = 2 mod 7 = 2 <- collision
1 1 (2*1+3*1^2) mod 7 = (2 + 3) mod 7 = 5 mod 7 = 5 <- collision
2 1 (2*1+3*2^2) mod 7 = (2 + 12) mod 7 = 14 mod 7 = 0 <- [1, e, 3, 12, e, 20, 5]
So
[1, empty, 3, 12, empty, 20, 5]
Here is how it works, each time collision happens, quadratic probing is going to be used (with i=1,2,..) until there is a free space available in the hash table: