I made a population pyramid, but I can't get the same X values axis from the 2 graphs.
X-axis has to be dynamic: the highest value of the 2 graphs.
Link :
https://public.tableau.com/app/profile/laterr2/viz/PyramidAge/Sheet1
I calculated my Age :
DATEDIFF('year',[Date de naissance],[Date de derniere transmission])
I made group ages :
// Group ages.
IF [Age]<18 THEN
"0-17"
ELSEIF [Age]<26 THEN
"18-25"
ELSEIF [Age]<36 THEN
"26-35"
ELSEIF [Age]<46 THEN
"36-45"
ELSEIF [Age]<56 THEN
"46-55"
ELSEIF [Age]<66 THEN
"56-65"
ELSE
"66+"
END
I made my Female group :
IF [Sexe]='FEMME' then 1 end
I made my Male group :
IF [Sexe]='HOMME' then 1 end
I tried to make a ref line with WINDOW_MIN and WINDOW_MAX ( according to https://www.thedataschool.co.uk/brian-scally/tableau-tip-formatting-the-axis-correctly-on-a-population-pyramid ) but did not manage to get it work.
Any help ?
Thanks
Related
I could really use some suggestions here :
So, what I am supposed to do is simulate a containment scenario over a graph (meaning that every node of the network will, eventually, join the convex hull defined by the state of the leaders of the graph; in this case, leaders are stationary and graph's topology is fixed). the procedure is based on the following :
Xi(k+1) = Xi(k) if node i is a leader on the graph
Xi(k+1) = Xi(k) + ∑Aij*(Xj(k)-Xi(k)) if node i is a follower on the graph
[if interested, more info in "containment control with
multiple stationary or dynamic leaders under a directed interaction graph]
My idea for the code is to start with a random input and elaborate it until containment is reached. what i have done so far :
clear all
clc
%%adjacency matrix; 4 leaders; 10 followers
%%leaders are not connected to other nodes
a=round(rand(14,14));
a=round((a+a')/2);
a([1:4],[1:end])=0;
a([1:end],[1:4])=0;
a=max(eye(14),a);
%%random inputs for leaders and followers; convex hull;
sl=randi(10,[2,4]);
cv=convhull(sl');
sf=randi(10,[2,10]);
s=[sl sf];
%%i need to compare the state of each follower with the convex hull
ssf=sf(:);
for i = 1 : length(ssf)
b = ssf(i)==cv(1:end);
c(:,i) = b;
end
j=sum(c);
s0=zeros(size(s));
%%go on with the procedure until j isnt a ones(1,20)
while (sum(j) <= 20)
s0=s;
for i = 1 : 14
for j = 1 : 14
s0(:,i) = s0(:,i) + a(i,j)*(s(:,j) - s(:,i));
end
end
s0=s;
sl=s(1:2,1:4);
sf=s(1:2,5:end);
ssf=sf(:);
for i = 1 : length(ssf)
b = ssf(i)==cv(1:end);
c(:,i) = b;
end
j=sum(c);
end
There is something wrong with the code, but I'm not able to fix it
I am Beginner in Matlab, i would like to plot system concentration vs time plot at a certain time interval following is the code that i have written
%Input function of 9 samples with activity and time calibrated with Well
%counter value approx : 1.856 from all 9 input values of 3 patients
function c_o = Sample_function(td,t_max,A,B)
t =(0 : 100 :5000); % time of the sample post injection in mins
c =(0 : 2275.3 :113765);
A_max= max(c); %Max value of Concentration (Peak of the curve)
if (t >=0 && t <= td)
c_o(t)=0;
else if(td <=t && t<=t_max)
c_o(t)= A_max*(t-td);
else if(t >= t_max)
c_o(t)=(A(1)*exp(-B(1)*(t-t_max)))+(A(2)*exp(-B(2)*(t- t_max)))+...
(A(3)*exp(-B(3)*(t-t_max)));
end
fprintf('plotting Data ...\n');
hold on;
figure;
plot(c_o);
xlabel('Activity of the sample Ba/ml ');
ylabel('time of the sample in minutes');
title (' Input function: Activity sample VS time ');
pause;
end
I am getting following error
Operands to the || and && operators must be convertible to logical scalar values.
Error in Sample_function (line 18)
if (t >=0 && t <= td)
Kindly .Let me know if my logic is incorrect
Your t is not a single value to compare with 0 so it cannot evaluate to true or false.
You want to do this with logical indexing
c_o = zeros(size(t));
c_o(t>=0 & t<=td) = 0; % this line is actually redundant and unnecessary since we initialized the vector to zeros
c_o(t>td & t<=t_max) = A_max*(t(t>td & t<=t_max)-td);
c_o(t>t_max) = (A(1)*exp(-B(1)*(t(t>t_max)-t_max)))+(A(2)*exp(-B(2)*(t(t>t_max)- t_max)))...
+ (A(3)*exp(-B(3)*(t(t>t_max)-t_max)));
You could also make this a little prettier (and easier to read) by assigning the logical indexes to variables:
reg1 = (t>=0 & t<=td);
reg2 = (t>td & t<=t_max);
reg3 = (t>t_max);
Then, for instance, the second assignment becomes the much more readable:
c_o(reg2) = A_max*(t(reg2)-td);
t is written as a array of numbers. So, it can't be compared with a scalar value ex. 0.
Try it in a for loop
for i=1:length(t)
if (t(i) >=0 && t(i) <= td)
c_o(t(i))=0;
else if(td <=t(i) && t(i)<=t_max)
c_o(t(i)))= A_max*(t(i)-td);
else if(t(i) >= t_max)
c_o(t)=(A(1)*exp(-B(1)*(t(i)-t_max)))+(A(2)*exp(-B(2)*(t(i)- t_max)))...
+ (A(3)*exp(-B(3)*(t(i)-t_max)));
end
end
Up to now, I used 3 loops to build a matrix, but it takes such a long time that I would like to vectorize it. But either it's not possible, or I took the wrong way to do it. Anyway, I am in front of a wall, and I need your help.
Here are the loops :
AngleList = [0 : 10 : 300]; % 31 elements
Fx_mat is a (1000,120,31) matrix, 31 is for the 31 elements corresponding to AngleList.
for Aaa = 1:Nb_loop1 % Nb_loop1 = 3
for Bbb = 1:Nb_loop2 % Nb_loop2 = 120
for Ccc = 1:Nb_loop3 % Nb_loop3 = 1000
Angle = rand()*300; % Then Angle is between 0 and 300
Fx_mat_interp(Aaa,Bbb,Ccc) = interp1(AngleList, Fx_mat(Ccc,Bbb,:), Angle);
end
end
end
What I first tried to do is to create matrix with my datas :
m_Angle = rand(Nb_loop3,Nb_loop2)*300 % 1000x120 matrix
m_AngleList = permute(reshape(repmat(AngleList,Nb_loop3,Nb_loop2),Nb_loop1,Nb_loop3,Nb_loop2),[1 3 2]);
% I repeat my AngleList vector in a 1000x120x31 matrix
for Aaa = 1:Nb_loop1
Fx_mat_interp(Aaa,:,:) = ?????(m_AngleList, Fx_mat(Nb_loop3,Nb_loop2,:), m_Angle);
end
I would like to replace ????? with the equivalent to interp1, but I can't find it.
Do you have any idea to help me please ?
P.S: And a lot of great thinks for all of you for this new year.
I am working on a scilab program to average a 3d matrix in cubes.This is mostly done, but I want to set the size to a given sum,(the voxels all add up to a set amount in each cube)and I keep breaking the program every time I try to add this feature.
function totSAR = comptS(Material, SAR, a, b, c, a1, b1, c1, grams)
si=size(SAR);
radius=0;
OK=0;
totwei=0;
totSAR=0;
totpx=0;
while (totwei<=grams*1e-3 && OK==0)
totwei2=totwei;
totSAR2=totSAR;
totpx2=totpx;
totwei=0;
totpx=0;
totSAR1=0;
totSAR=0;
radius=radius+1;
for o=-radius:radius
rado=floor(sqrt(radius^2-o^2));
for m=-rado:rado
radm=floor(sqrt(rado^2-m^2));
for n=-radm:radm
if (a+m >= 1 && a+m <= si(1) && b+n >=1 && b+n <=si(2) && c+o >= 1 && c+o <si(3))
if totwei<=10e-3
totwei=totwei+a1*b1*c1*Material(a+m, b+n, c+o);
if SAR(a+m, b+n, c+o)>0
totpx=totpx+1;
totSAR=totSAR+SAR(a+m, b+n, c+o);
end
end
end
end
end
end
if totSAR==totSAR1
OK=1;
end
end
coefw = (grams*1e-3 - totwei2)/(totwei-totwei2);
totpxs = coefw*(totpx-totpx2);
totSARs = coefw*(totSAR-totSAR2);
totpx;
if totpx>0
totSAR=(totSAR2+totSARs)/(totpx2+totpxs);
end
end
Sorry that I am a bit of a newbie, and thanks for the help!
Your only problem is that you aren't updating the totwei variable when you create a voxel.You will need to subtract the value of the voxel from the remaining desired weight, and add it to the total weight.
totwei = totwei + voxel
valleft = valleft - voxel
hey I'm doing a biomechanical model of the L2 vertebra and I have found a problem which I had problems solving.
count = 0;
for ii = 1:num_g
for jj = idx(ii)
if id(jj) >= -1 & count <= dimension
count = count + 1;
S_ef_equivalent(1,count) = S_ef(1,jj);
minidx(1,count) = jj;
end
end
end
I have this part of code where is going to pick up the values with the lowest density and remodel the bone and it works but the code after running a cycle of 3 times stops evolving and don't remodel the rest of the plate ( wich will give me the RX of a bone ). So my question is how can I solve this problem.
How can I make a cycle without repeating the point from the cycle used before?
thanks