Category: News
Minimize difference between two data sets
I have two data sets, one will not change while the other depends on two variables, say A and B. I have a function that takes A and B, recomputes the one data set using A and B using a seperate function (i.e. it calls another function), then spits out a value for how well the two data sets compare. The function I described works alone (call it my_func). When I try to minimize, is when it fails. I have tried multiple methods: lsqnonlin, fminsearch, and fminunc. All follow a similar format being [output] = [method](@(A,B) my_func(A,B), [A B]) and they all return a failure to continue due to not enough input arguments.
Am I using these methods incorrectly? I am not sure why the will not begin to solve. Is there another method that I am unaware of that would work better for this application? Thank you for any guidance.I have two data sets, one will not change while the other depends on two variables, say A and B. I have a function that takes A and B, recomputes the one data set using A and B using a seperate function (i.e. it calls another function), then spits out a value for how well the two data sets compare. The function I described works alone (call it my_func). When I try to minimize, is when it fails. I have tried multiple methods: lsqnonlin, fminsearch, and fminunc. All follow a similar format being [output] = [method](@(A,B) my_func(A,B), [A B]) and they all return a failure to continue due to not enough input arguments.
Am I using these methods incorrectly? I am not sure why the will not begin to solve. Is there another method that I am unaware of that would work better for this application? Thank you for any guidance. I have two data sets, one will not change while the other depends on two variables, say A and B. I have a function that takes A and B, recomputes the one data set using A and B using a seperate function (i.e. it calls another function), then spits out a value for how well the two data sets compare. The function I described works alone (call it my_func). When I try to minimize, is when it fails. I have tried multiple methods: lsqnonlin, fminsearch, and fminunc. All follow a similar format being [output] = [method](@(A,B) my_func(A,B), [A B]) and they all return a failure to continue due to not enough input arguments.
Am I using these methods incorrectly? I am not sure why the will not begin to solve. Is there another method that I am unaware of that would work better for this application? Thank you for any guidance. optimization, variable MATLAB Answers — New Questions
How to validate that one datetime is greater than another
My class takes two datetimes startTime and endTime as input arguments. I would like to use argument validation to force endTime to be later than startTime, but mustBeGreaterThan does not accept datetimes.My class takes two datetimes startTime and endTime as input arguments. I would like to use argument validation to force endTime to be later than startTime, but mustBeGreaterThan does not accept datetimes. My class takes two datetimes startTime and endTime as input arguments. I would like to use argument validation to force endTime to be later than startTime, but mustBeGreaterThan does not accept datetimes. argument validation, datetime MATLAB Answers — New Questions
Slected Email Highlight Color
Hello,
When I select an email in Outlook on PC, the background color slightly changes to show that you have selected that email. I am visually impared, and this slight change in color is hard for me to see. Is there a way to change the selected email highlight color to a higher contrast color?
Thank you
Hello,When I select an email in Outlook on PC, the background color slightly changes to show that you have selected that email. I am visually impared, and this slight change in color is hard for me to see. Is there a way to change the selected email highlight color to a higher contrast color?Thank you Read More
Kayla Irick
this is for @email address removed for privacy reasons just want to know if you are seeing this message
this is for @email address removed for privacy reasons just want to know if you are seeing this message Read More
Make charts uniform
Hello everyone, I’m a universtiy student and currently writing a paper; one of the things that I’m add to it are 4 charts, histograms to be precise; one neat way to fit them nicely into the paper is by turining a page horizontal (which required me to apply 2 contiguous breaks) and placing each of them in a “quadrant”; each chart has an external label called “Figure x”; the labels are above their respective charts and the ones on the left are on the left of the page and the ones on the right are on the right margin of the page. Long story short, the charts for some obscure reason are hyper messy to get to “snap” to some sort of grid, they do no automatically “shape” themselves into conformity with the other charts, one even appeared with a smaller font. My goal is to have every single detail of the chart (except for the relevant values and thus the height of the bars) to be identical; chart name x, y distance from top right corner? Same internal distance for every chart! And so on basically; sorry for the long and confused message but I’m sleep deprived and frustrated. <3
Hello everyone, I’m a universtiy student and currently writing a paper; one of the things that I’m add to it are 4 charts, histograms to be precise; one neat way to fit them nicely into the paper is by turining a page horizontal (which required me to apply 2 contiguous breaks) and placing each of them in a “quadrant”; each chart has an external label called “Figure x”; the labels are above their respective charts and the ones on the left are on the left of the page and the ones on the right are on the right margin of the page. Long story short, the charts for some obscure reason are hyper messy to get to “snap” to some sort of grid, they do no automatically “shape” themselves into conformity with the other charts, one even appeared with a smaller font. My goal is to have every single detail of the chart (except for the relevant values and thus the height of the bars) to be identical; chart name x, y distance from top right corner? Same internal distance for every chart! And so on basically; sorry for the long and confused message but I’m sleep deprived and frustrated. <3 Read More
fminunc not converging objective function
I’m trying to minimize the following from observations data (which now is synthetic):
Observation generation:
Fs = 80E6;
lags = (-10:10)’;
tau = lags/Fs;
bw = 0.1;
[obs, obs_A, obs_C] = Raa_parabola(lags, bw);
function [y, A, C] = Raa_parabola(lags,bw)
%RAA_PARABOLA generates a parabola function given a lag vector.
% tau: time vector
% bw: bandwidth at RF
x2 = 1/bw;
x1 = -x2;
A = 1/x1/x2;
B = 0;
C = A*x1*x2;
y = A*lags.^2 + B*lags + C;
end
Which generates a parabola given a tau vector and a bandwidth bw (Fig. 1)
Adding phase to this observations:
f = 420E3;
ph = exp(1j*2*pi*f*tau);
obs = obs.*ph;
Thus the objective function will have 2 parabola parameters and 1 last parameter to obtain the phase, defined as:
function F = myfunc1(x, o, lags, tau)
m_mag = x(1)*lags.^2 + x(2); % magnitude
m_phase = exp(1j*2*pi*x(3)*tau); % phase
m = m_mag.*m_phase; % model
e = m – o; % error = model – observations
F = e’*e; % mean square error
end
With the idea to generate a kinda least squares minimization and use F as the mean square error.
x0 = [0,0,0];
fun = @(x) myfunc1(x, obs, lags, tau);
options = optimoptions(‘fminunc’, ‘Display’, ‘iter’, ‘StepTolerance’, 1e-20, ‘FunctionTolerance’, 1e-9, …
‘MaxFunctionEvaluations’, 300, ‘DiffMinChange’, 1e-5);
[x,fopt] = fminunc(fun, x0,options);
fprintf("Observation coefficients: A = %.2f, C = %.2fn",obs_A,obs_C)
disp(x);
y = x(1)*lags.^2 + x(2);
y = y.*exp(1j*2*pi*x(3)*tau);
figure(1); clf;
subplot(4,1,1); plot(lags,real(obs),’LineWidth’,2);hold on;
subplot(4,1,2); plot(lags,imag(obs),’LineWidth’,2);hold on;
subplot(4,1,3); plot(lags,abs(obs),’LineWidth’,2);hold on;
subplot(4,1,4); plot(lags,angle(obs)*180/pi,’LineWidth’,2);hold on;
subplot(4,1,1); plot(lags,real(y),’LineWidth’,1.5); legend(‘Obs’,’Model’);
subplot(4,1,2); plot(lags,imag(y),’LineWidth’,1.5); legend(‘Obs’,’Model’);
subplot(4,1,3); plot(lags,abs(y),’LineWidth’,2);hold on;
subplot(4,1,4); plot(lags,angle(y)*180/pi,’LineWidth’,2);hold on;
Notice that values x(1) and x(2) converge to a valid point (for me) but parameter 3 should be 420E3.
Where is my misconception?
Thank you very much.I’m trying to minimize the following from observations data (which now is synthetic):
Observation generation:
Fs = 80E6;
lags = (-10:10)’;
tau = lags/Fs;
bw = 0.1;
[obs, obs_A, obs_C] = Raa_parabola(lags, bw);
function [y, A, C] = Raa_parabola(lags,bw)
%RAA_PARABOLA generates a parabola function given a lag vector.
% tau: time vector
% bw: bandwidth at RF
x2 = 1/bw;
x1 = -x2;
A = 1/x1/x2;
B = 0;
C = A*x1*x2;
y = A*lags.^2 + B*lags + C;
end
Which generates a parabola given a tau vector and a bandwidth bw (Fig. 1)
Adding phase to this observations:
f = 420E3;
ph = exp(1j*2*pi*f*tau);
obs = obs.*ph;
Thus the objective function will have 2 parabola parameters and 1 last parameter to obtain the phase, defined as:
function F = myfunc1(x, o, lags, tau)
m_mag = x(1)*lags.^2 + x(2); % magnitude
m_phase = exp(1j*2*pi*x(3)*tau); % phase
m = m_mag.*m_phase; % model
e = m – o; % error = model – observations
F = e’*e; % mean square error
end
With the idea to generate a kinda least squares minimization and use F as the mean square error.
x0 = [0,0,0];
fun = @(x) myfunc1(x, obs, lags, tau);
options = optimoptions(‘fminunc’, ‘Display’, ‘iter’, ‘StepTolerance’, 1e-20, ‘FunctionTolerance’, 1e-9, …
‘MaxFunctionEvaluations’, 300, ‘DiffMinChange’, 1e-5);
[x,fopt] = fminunc(fun, x0,options);
fprintf("Observation coefficients: A = %.2f, C = %.2fn",obs_A,obs_C)
disp(x);
y = x(1)*lags.^2 + x(2);
y = y.*exp(1j*2*pi*x(3)*tau);
figure(1); clf;
subplot(4,1,1); plot(lags,real(obs),’LineWidth’,2);hold on;
subplot(4,1,2); plot(lags,imag(obs),’LineWidth’,2);hold on;
subplot(4,1,3); plot(lags,abs(obs),’LineWidth’,2);hold on;
subplot(4,1,4); plot(lags,angle(obs)*180/pi,’LineWidth’,2);hold on;
subplot(4,1,1); plot(lags,real(y),’LineWidth’,1.5); legend(‘Obs’,’Model’);
subplot(4,1,2); plot(lags,imag(y),’LineWidth’,1.5); legend(‘Obs’,’Model’);
subplot(4,1,3); plot(lags,abs(y),’LineWidth’,2);hold on;
subplot(4,1,4); plot(lags,angle(y)*180/pi,’LineWidth’,2);hold on;
Notice that values x(1) and x(2) converge to a valid point (for me) but parameter 3 should be 420E3.
Where is my misconception?
Thank you very much. I’m trying to minimize the following from observations data (which now is synthetic):
Observation generation:
Fs = 80E6;
lags = (-10:10)’;
tau = lags/Fs;
bw = 0.1;
[obs, obs_A, obs_C] = Raa_parabola(lags, bw);
function [y, A, C] = Raa_parabola(lags,bw)
%RAA_PARABOLA generates a parabola function given a lag vector.
% tau: time vector
% bw: bandwidth at RF
x2 = 1/bw;
x1 = -x2;
A = 1/x1/x2;
B = 0;
C = A*x1*x2;
y = A*lags.^2 + B*lags + C;
end
Which generates a parabola given a tau vector and a bandwidth bw (Fig. 1)
Adding phase to this observations:
f = 420E3;
ph = exp(1j*2*pi*f*tau);
obs = obs.*ph;
Thus the objective function will have 2 parabola parameters and 1 last parameter to obtain the phase, defined as:
function F = myfunc1(x, o, lags, tau)
m_mag = x(1)*lags.^2 + x(2); % magnitude
m_phase = exp(1j*2*pi*x(3)*tau); % phase
m = m_mag.*m_phase; % model
e = m – o; % error = model – observations
F = e’*e; % mean square error
end
With the idea to generate a kinda least squares minimization and use F as the mean square error.
x0 = [0,0,0];
fun = @(x) myfunc1(x, obs, lags, tau);
options = optimoptions(‘fminunc’, ‘Display’, ‘iter’, ‘StepTolerance’, 1e-20, ‘FunctionTolerance’, 1e-9, …
‘MaxFunctionEvaluations’, 300, ‘DiffMinChange’, 1e-5);
[x,fopt] = fminunc(fun, x0,options);
fprintf("Observation coefficients: A = %.2f, C = %.2fn",obs_A,obs_C)
disp(x);
y = x(1)*lags.^2 + x(2);
y = y.*exp(1j*2*pi*x(3)*tau);
figure(1); clf;
subplot(4,1,1); plot(lags,real(obs),’LineWidth’,2);hold on;
subplot(4,1,2); plot(lags,imag(obs),’LineWidth’,2);hold on;
subplot(4,1,3); plot(lags,abs(obs),’LineWidth’,2);hold on;
subplot(4,1,4); plot(lags,angle(obs)*180/pi,’LineWidth’,2);hold on;
subplot(4,1,1); plot(lags,real(y),’LineWidth’,1.5); legend(‘Obs’,’Model’);
subplot(4,1,2); plot(lags,imag(y),’LineWidth’,1.5); legend(‘Obs’,’Model’);
subplot(4,1,3); plot(lags,abs(y),’LineWidth’,2);hold on;
subplot(4,1,4); plot(lags,angle(y)*180/pi,’LineWidth’,2);hold on;
Notice that values x(1) and x(2) converge to a valid point (for me) but parameter 3 should be 420E3.
Where is my misconception?
Thank you very much. minimization, fminunc, fmincon MATLAB Answers — New Questions
Remove Matlab three dots
How to remove the three dots? I even have three three dots this time, even more annoying as usual.
They just appear randomly when I edit a loop sometimes and I cannot remove them anymore.
Edit: I want to remove this behavior, if any options allows it. Or at least, understand why it apppears.How to remove the three dots? I even have three three dots this time, even more annoying as usual.
They just appear randomly when I edit a loop sometimes and I cannot remove them anymore.
Edit: I want to remove this behavior, if any options allows it. Or at least, understand why it apppears. How to remove the three dots? I even have three three dots this time, even more annoying as usual.
They just appear randomly when I edit a loop sometimes and I cannot remove them anymore.
Edit: I want to remove this behavior, if any options allows it. Or at least, understand why it apppears. matlab, loop MATLAB Answers — New Questions
How can I activate to close outlook session after a certain time on inactivity?
usually you open the browser and outlook ask you: do you want to keep session opened? I usually say no, so that after a time I am not on the computer or leave I know the session will close, but this doesn’t happen any more, and there is no way I can find how to set to close the session after some inactivity time.
thanks in advance
usually you open the browser and outlook ask you: do you want to keep session opened? I usually say no, so that after a time I am not on the computer or leave I know the session will close, but this doesn’t happen any more, and there is no way I can find how to set to close the session after some inactivity time. thanks in advance Read More
Norton 360 install on Windows 11 Pro (ARM)
I recently installed Windows 11 Pro (ARM) Version 23H2 on my new Macbook Pro using
VMWare Fusion Pro (13.5.2).
I am trying to install Norton 360. I open the Microsoft Store Application (after installing the application) and found Norton 360. I went to install and received the following error:
“A problem has occurred that needs your attention:
This process is unable to continue due to a system service that may not be
installed or cannot be started. Please repair your installation of Windows
before continuing.”
I contacted Norton and they say to get Microsoft to fix the problem with the installation.
Microsoft says to contact the community since it’s a virtual machine.
Has anyone been able to actually install Norton 360 on Windows 11 Pro on an ARM machine?
Anyone have any suggestions on what I can try?
I recently installed Windows 11 Pro (ARM) Version 23H2 on my new Macbook Pro usingVMWare Fusion Pro (13.5.2). I am trying to install Norton 360. I open the Microsoft Store Application (after installing the application) and found Norton 360. I went to install and received the following error:”A problem has occurred that needs your attention:This process is unable to continue due to a system service that may not beinstalled or cannot be started. Please repair your installation of Windowsbefore continuing.” I contacted Norton and they say to get Microsoft to fix the problem with the installation.Microsoft says to contact the community since it’s a virtual machine. Has anyone been able to actually install Norton 360 on Windows 11 Pro on an ARM machine?Anyone have any suggestions on what I can try? Read More
Excel 2019. VBA select rows on criteria and delete up whole sheet, not looping up through the data?
EXCEL 2019
Windows 10
I receive large text files that contain rows of data that I need to keep, and some that I do not.
The code below is designed to select, colour and then delete those rows that I do not need.
As this code will be run on very large worksheets I wanted a visual way to see exactly what the code is selecting before committing to the deletion. This is a safeguard for my poor coding skills.
so what this code does is it sets up the variables based on criteria working on finding the startRow and endRow based on the “Complete name” row and the preceding blank row.
Then it *SHOULD* colour the appropiate rows in yellow from Column A to C between startRow and endRow working its way up the whole sheet.
It then counts the number of rows with the yellow colour and prompts with a message box to delete the rows or not.
If I choose Yes, it deletes the rows with yellow color and then displays a message with the count of deleted rows.
If I choose No, it displays the count of rows marked for deletion and ends the sub so I can visually check it has selected the right rows.
The code below is the last in many different versions and it works up to a point.
It is the bits that do not work that I need a helping hand with please.
After running the sub, it only selects the first set of rows for deletion but not all of them working up all of the rows in the sheet.
If I click NO, it provides the message with the count of rows marked for deletion BUT it does not leave the selected rows coloured yellow.
If I click YES, it only deletes one set of rows but does not work all of the way up the sheet.
Sample workbook attached.
Sub HighlightDeleteRows()
Dim ws As Worksheet
Dim lastRow As Long
Dim cell As Range
Dim startRow As Long
Dim endRow As Long
Dim i As Long
Dim yellowCount As Integer
‘ Set the worksheet
Set ws = ThisWorkbook.Worksheets(“Media”)
‘ Find the last used row in column A
lastRow = ws.Cells(ws.Rows.Count, “A”).End(xlUp).Row
‘ Loop from the last used row up to find the first cell with the text “Complete name”
For i = lastRow To 1 Step -1
If ws.Cells(i, 1).Value = “Complete name” Then
startRow = i + 1
Exit For
End If
Next i
‘ Find the endRow by looking for the first blank row above startRow
For i = startRow – 1 To 1 Step -1
If WorksheetFunction.CountA(ws.Rows(i)) = 0 Then
endRow = i + 1
Exit For
End If
Next i
‘ Color rows in between startRow and endRow from Column A to C
For i = startRow To endRow – 1
ws.Range(“A” & i & “:C” & i).Interior.Color = RGB(255, 255, 0) ‘ Yellow color RGB value
Next i
‘ Count the number of rows with the color yellow
yellowCount = ws.Range(“A” & startRow & “:A” & endRow – 1).SpecialCells(xlCellTypeConstants, 6).Count
‘ Ask user to delete rows
Dim answer As VbMsgBoxResult
answer = MsgBox(“Delete Rows?”, vbYesNo)
‘ Delete or Mark Rows based on user input
If answer = vbYes Then
‘ Delete rows with yellow color
ws.Range(“A” & startRow & “:A” & endRow – 1).SpecialCells(xlCellTypeConstants, 6).EntireRow.Delete
MsgBox yellowCount & ” Rows Deleted”
Else
MsgBox yellowCount & ” Rows Marked For Deletion!”
End If
End Sub
EXCEL 2019Windows 10I receive large text files that contain rows of data that I need to keep, and some that I do not.The code below is designed to select, colour and then delete those rows that I do not need. As this code will be run on very large worksheets I wanted a visual way to see exactly what the code is selecting before committing to the deletion. This is a safeguard for my poor coding skills. so what this code does is it sets up the variables based on criteria working on finding the startRow and endRow based on the “Complete name” row and the preceding blank row.Then it *SHOULD* colour the appropiate rows in yellow from Column A to C between startRow and endRow working its way up the whole sheet. It then counts the number of rows with the yellow colour and prompts with a message box to delete the rows or not.If I choose Yes, it deletes the rows with yellow color and then displays a message with the count of deleted rows.If I choose No, it displays the count of rows marked for deletion and ends the sub so I can visually check it has selected the right rows. The code below is the last in many different versions and it works up to a point.It is the bits that do not work that I need a helping hand with please. After running the sub, it only selects the first set of rows for deletion but not all of them working up all of the rows in the sheet. If I click NO, it provides the message with the count of rows marked for deletion BUT it does not leave the selected rows coloured yellow.If I click YES, it only deletes one set of rows but does not work all of the way up the sheet. Sample workbook attached. Sub HighlightDeleteRows()
Dim ws As Worksheet
Dim lastRow As Long
Dim cell As Range
Dim startRow As Long
Dim endRow As Long
Dim i As Long
Dim yellowCount As Integer
‘ Set the worksheet
Set ws = ThisWorkbook.Worksheets(“Media”)
‘ Find the last used row in column A
lastRow = ws.Cells(ws.Rows.Count, “A”).End(xlUp).Row
‘ Loop from the last used row up to find the first cell with the text “Complete name”
For i = lastRow To 1 Step -1
If ws.Cells(i, 1).Value = “Complete name” Then
startRow = i + 1
Exit For
End If
Next i
‘ Find the endRow by looking for the first blank row above startRow
For i = startRow – 1 To 1 Step -1
If WorksheetFunction.CountA(ws.Rows(i)) = 0 Then
endRow = i + 1
Exit For
End If
Next i
‘ Color rows in between startRow and endRow from Column A to C
For i = startRow To endRow – 1
ws.Range(“A” & i & “:C” & i).Interior.Color = RGB(255, 255, 0) ‘ Yellow color RGB value
Next i
‘ Count the number of rows with the color yellow
yellowCount = ws.Range(“A” & startRow & “:A” & endRow – 1).SpecialCells(xlCellTypeConstants, 6).Count
‘ Ask user to delete rows
Dim answer As VbMsgBoxResult
answer = MsgBox(“Delete Rows?”, vbYesNo)
‘ Delete or Mark Rows based on user input
If answer = vbYes Then
‘ Delete rows with yellow color
ws.Range(“A” & startRow & “:A” & endRow – 1).SpecialCells(xlCellTypeConstants, 6).EntireRow.Delete
MsgBox yellowCount & ” Rows Deleted”
Else
MsgBox yellowCount & ” Rows Marked For Deletion!”
End If
End Sub Read More
How to find x values where y= 0 using newtons method and secant method?
I´ve drawn up newtons method in an easy function as:
function [x, iter] = newton(f, df, x)
maxiter = 1000;
iter = 0;
d = 100;
while abs(d) > sqrt(eps)*abs(x) && iter < maxiter
iter = iter + 1;
d = -f(x)/df(x);
x = x + d;
end
if iter == maxiter
disp(‘Maximum number of iterations performed. Answer is probably wrong.’)
end
end
The secant method i’ve drawn up like this:
function [xout,iter] = sekant(f,x,x1)
iter = 0;
maxiter = 1000;
while abs(x1-x) > 1e-6
iter = iter + 1;
d = (f(x1) – f(x))./(x1-x);
xout = (x1-f(x1)./d);
x = x1;
x1 = xout;
if iter == maxiter
disp(‘No points of zeros found’)
break
end
end
end
Here is my problem, I wish to put both of them together to find points where y = 0 for several functions as polynomials and differential eqations. My thought process has been that i need to find an interval of x values where these methods are used and with them make the inteval smaller untill im close enough to find the "approximation" or actual value of 0.I´ve drawn up newtons method in an easy function as:
function [x, iter] = newton(f, df, x)
maxiter = 1000;
iter = 0;
d = 100;
while abs(d) > sqrt(eps)*abs(x) && iter < maxiter
iter = iter + 1;
d = -f(x)/df(x);
x = x + d;
end
if iter == maxiter
disp(‘Maximum number of iterations performed. Answer is probably wrong.’)
end
end
The secant method i’ve drawn up like this:
function [xout,iter] = sekant(f,x,x1)
iter = 0;
maxiter = 1000;
while abs(x1-x) > 1e-6
iter = iter + 1;
d = (f(x1) – f(x))./(x1-x);
xout = (x1-f(x1)./d);
x = x1;
x1 = xout;
if iter == maxiter
disp(‘No points of zeros found’)
break
end
end
end
Here is my problem, I wish to put both of them together to find points where y = 0 for several functions as polynomials and differential eqations. My thought process has been that i need to find an interval of x values where these methods are used and with them make the inteval smaller untill im close enough to find the "approximation" or actual value of 0. I´ve drawn up newtons method in an easy function as:
function [x, iter] = newton(f, df, x)
maxiter = 1000;
iter = 0;
d = 100;
while abs(d) > sqrt(eps)*abs(x) && iter < maxiter
iter = iter + 1;
d = -f(x)/df(x);
x = x + d;
end
if iter == maxiter
disp(‘Maximum number of iterations performed. Answer is probably wrong.’)
end
end
The secant method i’ve drawn up like this:
function [xout,iter] = sekant(f,x,x1)
iter = 0;
maxiter = 1000;
while abs(x1-x) > 1e-6
iter = iter + 1;
d = (f(x1) – f(x))./(x1-x);
xout = (x1-f(x1)./d);
x = x1;
x1 = xout;
if iter == maxiter
disp(‘No points of zeros found’)
break
end
end
end
Here is my problem, I wish to put both of them together to find points where y = 0 for several functions as polynomials and differential eqations. My thought process has been that i need to find an interval of x values where these methods are used and with them make the inteval smaller untill im close enough to find the "approximation" or actual value of 0. newtons method, secant method MATLAB Answers — New Questions
1D advection diffusion with pdepe
Hello guys, i want to solve the 1D advection diffusion PDE in dimensionless form. The equation is the following:
dC/dW=(1/Pe)*d^2C/dX^2-dC/dX
I want to simlulate the dimensionless concentration for an finite element in x-Direction. Because the variables are dimensionless, my inital condition is C=1 for all X at W=0. Then, for W>0, the concentration must decrease, because of an Flow with an liquid with a concentration of zero. I want to plot the dimensinlos concentration C vs. W and X.
I think, my mistake are the boundary conditions, but I can´t find the solution.
I would be happy about a solution, to solve my problem.
This is my code so far:
function [c, f, s] = pdefun(X, W, C, dCdX)
Pe = 10;
c = 1;
f = (1/Pe)*dCdX;
s = -dCdX;
end
function C0 = ic(X)
C0 = 1;
end
function [pl, ql, pr, qr] = bc(Xl, Cl, Xr, Cr, W)
Pe=10;
pl =Cl;
ql = -1/Pe;
pr = Cr-1;
qr = 0;
end
X = linspace(0, 1, 10);
W = linspace(0, 10, 100);
m = 0;
sol = pdepe(m, @pdefun, @ic, @bc, X, W);
u = sol(:,:,1);
surf(X,W,u)
xlabel(‘X’)
ylabel(‘W’)
zlabel(‘u(W,X)’)
view([150 25])Hello guys, i want to solve the 1D advection diffusion PDE in dimensionless form. The equation is the following:
dC/dW=(1/Pe)*d^2C/dX^2-dC/dX
I want to simlulate the dimensionless concentration for an finite element in x-Direction. Because the variables are dimensionless, my inital condition is C=1 for all X at W=0. Then, for W>0, the concentration must decrease, because of an Flow with an liquid with a concentration of zero. I want to plot the dimensinlos concentration C vs. W and X.
I think, my mistake are the boundary conditions, but I can´t find the solution.
I would be happy about a solution, to solve my problem.
This is my code so far:
function [c, f, s] = pdefun(X, W, C, dCdX)
Pe = 10;
c = 1;
f = (1/Pe)*dCdX;
s = -dCdX;
end
function C0 = ic(X)
C0 = 1;
end
function [pl, ql, pr, qr] = bc(Xl, Cl, Xr, Cr, W)
Pe=10;
pl =Cl;
ql = -1/Pe;
pr = Cr-1;
qr = 0;
end
X = linspace(0, 1, 10);
W = linspace(0, 10, 100);
m = 0;
sol = pdepe(m, @pdefun, @ic, @bc, X, W);
u = sol(:,:,1);
surf(X,W,u)
xlabel(‘X’)
ylabel(‘W’)
zlabel(‘u(W,X)’)
view([150 25]) Hello guys, i want to solve the 1D advection diffusion PDE in dimensionless form. The equation is the following:
dC/dW=(1/Pe)*d^2C/dX^2-dC/dX
I want to simlulate the dimensionless concentration for an finite element in x-Direction. Because the variables are dimensionless, my inital condition is C=1 for all X at W=0. Then, for W>0, the concentration must decrease, because of an Flow with an liquid with a concentration of zero. I want to plot the dimensinlos concentration C vs. W and X.
I think, my mistake are the boundary conditions, but I can´t find the solution.
I would be happy about a solution, to solve my problem.
This is my code so far:
function [c, f, s] = pdefun(X, W, C, dCdX)
Pe = 10;
c = 1;
f = (1/Pe)*dCdX;
s = -dCdX;
end
function C0 = ic(X)
C0 = 1;
end
function [pl, ql, pr, qr] = bc(Xl, Cl, Xr, Cr, W)
Pe=10;
pl =Cl;
ql = -1/Pe;
pr = Cr-1;
qr = 0;
end
X = linspace(0, 1, 10);
W = linspace(0, 10, 100);
m = 0;
sol = pdepe(m, @pdefun, @ic, @bc, X, W);
u = sol(:,:,1);
surf(X,W,u)
xlabel(‘X’)
ylabel(‘W’)
zlabel(‘u(W,X)’)
view([150 25]) 1d advection diffusion, matlab, simulation MATLAB Answers — New Questions
How i use break in continues data?
Hello, this is my code for a diseases and I want to know the effect of drugs (blue line) if I stoped from days 30-60 and continue with microglia from days 60-180. It’s use break code or anything else?
clc;clear;
%parameter
delta=50;
gamma=75;
K1=10^-4;
K2=5*10^-4;
K3=10^-3;
K4=5*10^-3;
K5=10^-2;
K6=5*10^-2;
Ko=0.1;
n=6;
Oa=10;
Pa=100;
mu_1=10^-3;
mu_2=10^-3;
mu_3=10^-3;
mu_4=10^-3;
mu_5=10^-3;
mu_6=10^-3;
mu_o=10^-4;
mu_p= 10^-5;
%input for time
t(1)=0;
dt=0.01; %time interval
t=0:dt:180; %time span
%component for microglia
Mg = 0.047;
lambdaMf = 5*10^-2;
Fo = 3.36*10^-11;
KFo = 2.58*10^-11;
lambdaMa = 2.23*10^-2;
Ao = 0.14;
KAo = 10^-7;
beta = 10;
epsilon1 = 0.3333;
epsilon2 = 0.8;
lambdaM1Tb = 6*10^-3;
Tb=10^-6;
KTb = 2.5*10^-7;
makro1 = 0.02;
makro2 = 0.02;
dM1= 0.015;
dM2= 0.015;
tmakro1 = (Mg*(lambdaMf*(Fo/(Fo+KFo))+lambdaMa*(Ao/(Ao+KAo)))*(epsilon1*beta/beta*(epsilon1+epsilon2)))-(lambdaM1Tb*(Tb/(Tb+KTb)*makro1))-(dM1*makro1);
tmakro2 = (Mg*(lambdaMf*(Fo/(Fo+KFo))+lambdaMa*(Ao/(Ao+KAo)))*(epsilon2/beta*(epsilon1+epsilon2)))+(lambdaM1Tb*(Tb/(Tb+KTb))*makro1)-(dM2*makro2);
%component drugs
Abi = 10^-6;
lambdaN = 8*10^-4;
lambdaA = 8*10^-4;
daboM = 2*10^-3;
dabom = 10^-2; %clearance rate by macrophages
makrofag1 = 0;
makrofag2 = 0;
mikro1 = 0.02;
mikro2 = 0.02;
teta = 0.9;
h = 10;
Kaob = 7*10^-3;
AoB = 10^-8;
dtdab = Abi*(dt*(0.14*1.9*10^-4*exp(-1.9*10^-4)))+ (lambdaN*1)+(lambdaA*1)-(dabom*(makrofag1+(teta*makrofag2))+daboM*(mikro1+(teta*mikro2))*(1+h))*(AoB/(AoB+Kaob));
%initial condition with microglia
M1(1)=10;
M2(1)=0;
M3(1)=0;
M4(1)=0;
M5(1)=0;
M6(1)=0;
O(1)=0;
P(1)=0;
%initial condition without drugs
M12(1)=10;
M22(1)=0;
M32(1)=0;
M42(1)=0;
M52(1)=0;
M62(1)=0;
O2(1)=0;
P2(1)=0;
%initial condition with drugs
M14(1)=10;
M24(1)=0;
M34(1)=0;
M44(1)=0;
M54(1)=0;
M64(1)=0;
O4(1)=0;
P4(1)=0;
%empty array with microglia
T=zeros(length(t)+1,1); %empty array for t
M1=zeros(length(t)+1,1); %empty array for M1
M2=zeros(length(t)+1,1); %empty array for M2
M3=zeros(length(t)+1,1); %empty array for M3
M4=zeros(length(t)+1,1); %empty array for M4
M5=zeros(length(t)+1,1); %empty array for M5
M6=zeros(length(t)+1,1); %empty array for M6
O=zeros(length(t)+1,1); %empty array for O
P=zeros(length(t)+1,1); %empty array for P
sumter=K2*M2+K3*M3+K4*M4+K5*M5;
%empty array without drugs
M12=zeros(length(t)+1,1); %empty array for M1
M22=zeros(length(t)+1,1); %empty array for M2
M32=zeros(length(t)+1,1); %empty array for M3
M42=zeros(length(t)+1,1); %empty array for M4
M52=zeros(length(t)+1,1); %empty array for M5
M62=zeros(length(t)+1,1); %empty array for M6
O2=zeros(length(t)+1,1); %empty array for O
P2=zeros(length(t)+1,1); %empty array for P
sumter2=K2*M22+K3*M32+K4*M42+K5*M52;
%empty array with drugs depend time
M14=zeros(length(t)+1,1); %empty array for M1
M24=zeros(length(t)+1,1); %empty array for M2
M34=zeros(length(t)+1,1); %empty array for M3
M44=zeros(length(t)+1,1); %empty array for M4
M54=zeros(length(t)+1,1); %empty array for M5
M64=zeros(length(t)+1,1); %empty array for M6
O4=zeros(length(t)+1,1); %empty array for O
P4=zeros(length(t)+1,1); %empty array for P
sumter2=K2*M24+K4*M34+K4*M44+K5*M54;
for j = 1:length(t)
%with microglia
T(j+1)=T(j)+dt;
M1(j+1)=M1(j)+1./(1+exp(-T(j)));
M1(j+1) = M1(j)+(dt*(delta*M1(j+1)*(1-(M1(j+1)/gamma))-2*K1*M1(j+1)*M1(j+1)-M1(j+1)*sumter(j+1))-((Oa-n)*K6*M1(j+1)*M6(j+1))-((Pa-Oa)*Ko*M1(j+1)*O(j+1))-(mu_1*M1(j+1)));
M2(j+1) = M2(j)+(dt*(K1*M1(j)*M1(j)-K2*M1(j)*M2(j))-(mu_2*M2(j+1))-tmakro1-tmakro2);
M3(j+1) = M3(j)+(dt*(K2*M1(j)*M2(j)-K3*M1(j)*M3(j))-mu_3*M3(j));
M4(j+1) = M4(j)+(dt*(K3*M1(j)*M3(j)-K4*M1(j)*M4(j))-mu_4*M4(j));
M5(j+1) = M5(j)+(dt*(K4*M1(j)*M4(j)-K5*M1(j)*M5(j))-mu_5*M5(j));
M6(j+1) = M6(j)+(dt*(K5*M1(j)*M5(j)-K6*M1(j)*M6(j))-mu_6*M6(j));
O(j+1) = O(j)+(dt*(K6*M1(j)*M6(j)-Ko*M1(j)*O(j)-mu_o*O(j)));
P(j+1) = P(j)+(dt*(Ko*M1(j)*O(j)-mu_p*P(j)));
%without drugs
T(j+1)=T(j)+dt;
M12(j+1) = M12(j)+1./(1+exp(-T(j)));
M12(j+1) = M12(j)+(dt*(delta*M12(j+1)*(1-(M12(j+1)/gamma))-2*K1*M12(j+1)*M12(j+1)-M12(j+1)*sumter2(j+1))-((Oa-n)*K6*M12(j+1)*M62(j+1))-((Pa-Oa)*Ko*M12(j+1)*O2(j+1))-(mu_1*M12(j+1)));
M22(j+1) = M22(j)+(dt*(K1*M12(j)*M12(j)-K2*M12(j)*M22(j))-(mu_2*M22(j+1)));
M32(j+1) = M32(j)+(dt*(K2*M12(j)*M22(j)-K3*M12(j)*M32(j))-mu_3*M32(j));
M42(j+1) = M42(j)+(dt*(K3*M12(j)*M32(j)-K4*M12(j)*M42(j))-mu_4*M42(j));
M52(j+1) = M52(j)+(dt*(K4*M12(j)*M42(j)-K5*M12(j)*M52(j))-mu_5*M52(j));
M62(j+1) = M62(j)+(dt*(K5*M12(j)*M52(j)-K6*M12(j)*M62(j))-mu_6*M62(j));
O2(j+1) = O2(j)+(dt*(K6*M12(j)*M62(j)-Ko*M12(j)*O2(j)-mu_o*O2(j)));
P2(j+1) = P2(j)+(dt*(Ko*M12(j)*O2(j)-mu_p*P2(j)));
%with drugs depend by time
T(j+1)=T(j)+dt;
M14(j+1) = M14(j)+1./(1+exp(-T(j)));
M14(j+1) = M14(j)+(dt*(delta*M14(j+1)*(1-(M14(j+1)/gamma))-2*K1*M14(j+1)*M14(j+1)-M14(j+1)*sumter2(j+1))-((Oa-n)*K6*M14(j+1)*M64(j+1))-((Pa-Oa)*Ko*M14(j+1)*O4(j+1))-(mu_1*M14(j+1)));
M24(j+1) = M24(j)+(dt*(K1*M14(j)*M14(j)-K2*M14(j)*M24(j))-(mu_2*M24(j+1))-tmakro1-tmakro2-dtdab);
M34(j+1) = M34(j)+(dt*(K2*M14(j)*M24(j)-K3*M14(j)*M34(j))-mu_3*M34(j));
M44(j+1) = M44(j)+(dt*(K3*M14(j)*M34(j)-K4*M14(j)*M44(j))-mu_4*M44(j));
M54(j+1) = M54(j)+(dt*(K4*M14(j)*M44(j)-K5*M14(j)*M54(j))-mu_5*M54(j));
M64(j+1) = M64(j)+(dt*(K5*M14(j)*M54(j)-K6*M14(j)*M64(j))-mu_6*M64(j));
O4(j+1) = O4(j)+(dt*(K6*M14(j)*M64(j)-Ko*M14(j)*O4(j)-mu_o*O4(j)));
P4(j+1) = P4(j)+(dt*(Ko*M14(j)*O4(j)-mu_p*P4(j)));
end
subplot (2,2,1)
plot( T,M12,’r’,T,M1,’k’,T,M14,’b’,’Linewidth’,4)
legend (‘M1 without drugs’,’M1 with microglia’, ‘M1 with drugs’);
%xticks ([60 120 180 240 300 360 420 480 540 600 660 720 780 840 900 960 1020 1080])
xticks ([30 60 90 120 150 180 ])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title (‘M1’)
subplot (2,2,2)
plot(T,M22,’r’,T,M2,’k’,T,M24,’b’,’Linewidth’,4)
legend (‘M2 without drugs’,’M2 with microglia’,’M2 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([ 0 2 4 6 8 10 12 14 16])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title (‘M2’)
subplot (2,2,3)
plot(T,M32,’r’,T,M3,’k’,T,M34,’b’,’Linewidth’,4)
legend (‘M3 without drugs’,’M3 with microglia’,’M3 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.5 1 1.5 2 2.5 3 3.5])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title (‘M3’)
subplot (2,2,4)
plot(T,M42,’r’,T,M4,’k’,T,M44,’b’,’Linewidth’,4)
legend (‘M4 without drugs’,’M4 with microglia’, ‘M4 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.1 0.2 0.3 0.4 0.5])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title (‘M4’)
subplot (2,2,1)
plot(T,M52,’r’,T,M5,’k’,T,M54,’b’,’Linewidth’,4)
legend (‘M5 without drugs’,’M5 with microglia’, ‘M5 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.05 0.1 0.15 0.2])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title ("M5")
subplot (2,2,2)
plot(T,M62,’r’,T,M6,’k’,T,M64,’b’,’Linewidth’,4)
legend (‘M6 without drugs’,’M6 with microglia’,’M6 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.01 0.02 0.03 0.04 ])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title ("M6")
subplot (2,2,3)
plot(T,O2,’r’,T,O,’k’,T,O4,’b’,’Linewidth’,4)
legend (‘O without drugs’,’O with microglia’, ‘O with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.005 0.01 0.015 0.02])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title ("O")
subplot(2,2,4)
plot(T,P2,’r’,T,P,’k’,T,P4,’b’,’Linewidth’,4)
legend (‘P without drugs’,’P microglia’,’P with drugs’);
xticks ([30 60 90 120 150 180 ])
%yticks ([0 2 4 6 8 10 12])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘
(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title ("P")Hello, this is my code for a diseases and I want to know the effect of drugs (blue line) if I stoped from days 30-60 and continue with microglia from days 60-180. It’s use break code or anything else?
clc;clear;
%parameter
delta=50;
gamma=75;
K1=10^-4;
K2=5*10^-4;
K3=10^-3;
K4=5*10^-3;
K5=10^-2;
K6=5*10^-2;
Ko=0.1;
n=6;
Oa=10;
Pa=100;
mu_1=10^-3;
mu_2=10^-3;
mu_3=10^-3;
mu_4=10^-3;
mu_5=10^-3;
mu_6=10^-3;
mu_o=10^-4;
mu_p= 10^-5;
%input for time
t(1)=0;
dt=0.01; %time interval
t=0:dt:180; %time span
%component for microglia
Mg = 0.047;
lambdaMf = 5*10^-2;
Fo = 3.36*10^-11;
KFo = 2.58*10^-11;
lambdaMa = 2.23*10^-2;
Ao = 0.14;
KAo = 10^-7;
beta = 10;
epsilon1 = 0.3333;
epsilon2 = 0.8;
lambdaM1Tb = 6*10^-3;
Tb=10^-6;
KTb = 2.5*10^-7;
makro1 = 0.02;
makro2 = 0.02;
dM1= 0.015;
dM2= 0.015;
tmakro1 = (Mg*(lambdaMf*(Fo/(Fo+KFo))+lambdaMa*(Ao/(Ao+KAo)))*(epsilon1*beta/beta*(epsilon1+epsilon2)))-(lambdaM1Tb*(Tb/(Tb+KTb)*makro1))-(dM1*makro1);
tmakro2 = (Mg*(lambdaMf*(Fo/(Fo+KFo))+lambdaMa*(Ao/(Ao+KAo)))*(epsilon2/beta*(epsilon1+epsilon2)))+(lambdaM1Tb*(Tb/(Tb+KTb))*makro1)-(dM2*makro2);
%component drugs
Abi = 10^-6;
lambdaN = 8*10^-4;
lambdaA = 8*10^-4;
daboM = 2*10^-3;
dabom = 10^-2; %clearance rate by macrophages
makrofag1 = 0;
makrofag2 = 0;
mikro1 = 0.02;
mikro2 = 0.02;
teta = 0.9;
h = 10;
Kaob = 7*10^-3;
AoB = 10^-8;
dtdab = Abi*(dt*(0.14*1.9*10^-4*exp(-1.9*10^-4)))+ (lambdaN*1)+(lambdaA*1)-(dabom*(makrofag1+(teta*makrofag2))+daboM*(mikro1+(teta*mikro2))*(1+h))*(AoB/(AoB+Kaob));
%initial condition with microglia
M1(1)=10;
M2(1)=0;
M3(1)=0;
M4(1)=0;
M5(1)=0;
M6(1)=0;
O(1)=0;
P(1)=0;
%initial condition without drugs
M12(1)=10;
M22(1)=0;
M32(1)=0;
M42(1)=0;
M52(1)=0;
M62(1)=0;
O2(1)=0;
P2(1)=0;
%initial condition with drugs
M14(1)=10;
M24(1)=0;
M34(1)=0;
M44(1)=0;
M54(1)=0;
M64(1)=0;
O4(1)=0;
P4(1)=0;
%empty array with microglia
T=zeros(length(t)+1,1); %empty array for t
M1=zeros(length(t)+1,1); %empty array for M1
M2=zeros(length(t)+1,1); %empty array for M2
M3=zeros(length(t)+1,1); %empty array for M3
M4=zeros(length(t)+1,1); %empty array for M4
M5=zeros(length(t)+1,1); %empty array for M5
M6=zeros(length(t)+1,1); %empty array for M6
O=zeros(length(t)+1,1); %empty array for O
P=zeros(length(t)+1,1); %empty array for P
sumter=K2*M2+K3*M3+K4*M4+K5*M5;
%empty array without drugs
M12=zeros(length(t)+1,1); %empty array for M1
M22=zeros(length(t)+1,1); %empty array for M2
M32=zeros(length(t)+1,1); %empty array for M3
M42=zeros(length(t)+1,1); %empty array for M4
M52=zeros(length(t)+1,1); %empty array for M5
M62=zeros(length(t)+1,1); %empty array for M6
O2=zeros(length(t)+1,1); %empty array for O
P2=zeros(length(t)+1,1); %empty array for P
sumter2=K2*M22+K3*M32+K4*M42+K5*M52;
%empty array with drugs depend time
M14=zeros(length(t)+1,1); %empty array for M1
M24=zeros(length(t)+1,1); %empty array for M2
M34=zeros(length(t)+1,1); %empty array for M3
M44=zeros(length(t)+1,1); %empty array for M4
M54=zeros(length(t)+1,1); %empty array for M5
M64=zeros(length(t)+1,1); %empty array for M6
O4=zeros(length(t)+1,1); %empty array for O
P4=zeros(length(t)+1,1); %empty array for P
sumter2=K2*M24+K4*M34+K4*M44+K5*M54;
for j = 1:length(t)
%with microglia
T(j+1)=T(j)+dt;
M1(j+1)=M1(j)+1./(1+exp(-T(j)));
M1(j+1) = M1(j)+(dt*(delta*M1(j+1)*(1-(M1(j+1)/gamma))-2*K1*M1(j+1)*M1(j+1)-M1(j+1)*sumter(j+1))-((Oa-n)*K6*M1(j+1)*M6(j+1))-((Pa-Oa)*Ko*M1(j+1)*O(j+1))-(mu_1*M1(j+1)));
M2(j+1) = M2(j)+(dt*(K1*M1(j)*M1(j)-K2*M1(j)*M2(j))-(mu_2*M2(j+1))-tmakro1-tmakro2);
M3(j+1) = M3(j)+(dt*(K2*M1(j)*M2(j)-K3*M1(j)*M3(j))-mu_3*M3(j));
M4(j+1) = M4(j)+(dt*(K3*M1(j)*M3(j)-K4*M1(j)*M4(j))-mu_4*M4(j));
M5(j+1) = M5(j)+(dt*(K4*M1(j)*M4(j)-K5*M1(j)*M5(j))-mu_5*M5(j));
M6(j+1) = M6(j)+(dt*(K5*M1(j)*M5(j)-K6*M1(j)*M6(j))-mu_6*M6(j));
O(j+1) = O(j)+(dt*(K6*M1(j)*M6(j)-Ko*M1(j)*O(j)-mu_o*O(j)));
P(j+1) = P(j)+(dt*(Ko*M1(j)*O(j)-mu_p*P(j)));
%without drugs
T(j+1)=T(j)+dt;
M12(j+1) = M12(j)+1./(1+exp(-T(j)));
M12(j+1) = M12(j)+(dt*(delta*M12(j+1)*(1-(M12(j+1)/gamma))-2*K1*M12(j+1)*M12(j+1)-M12(j+1)*sumter2(j+1))-((Oa-n)*K6*M12(j+1)*M62(j+1))-((Pa-Oa)*Ko*M12(j+1)*O2(j+1))-(mu_1*M12(j+1)));
M22(j+1) = M22(j)+(dt*(K1*M12(j)*M12(j)-K2*M12(j)*M22(j))-(mu_2*M22(j+1)));
M32(j+1) = M32(j)+(dt*(K2*M12(j)*M22(j)-K3*M12(j)*M32(j))-mu_3*M32(j));
M42(j+1) = M42(j)+(dt*(K3*M12(j)*M32(j)-K4*M12(j)*M42(j))-mu_4*M42(j));
M52(j+1) = M52(j)+(dt*(K4*M12(j)*M42(j)-K5*M12(j)*M52(j))-mu_5*M52(j));
M62(j+1) = M62(j)+(dt*(K5*M12(j)*M52(j)-K6*M12(j)*M62(j))-mu_6*M62(j));
O2(j+1) = O2(j)+(dt*(K6*M12(j)*M62(j)-Ko*M12(j)*O2(j)-mu_o*O2(j)));
P2(j+1) = P2(j)+(dt*(Ko*M12(j)*O2(j)-mu_p*P2(j)));
%with drugs depend by time
T(j+1)=T(j)+dt;
M14(j+1) = M14(j)+1./(1+exp(-T(j)));
M14(j+1) = M14(j)+(dt*(delta*M14(j+1)*(1-(M14(j+1)/gamma))-2*K1*M14(j+1)*M14(j+1)-M14(j+1)*sumter2(j+1))-((Oa-n)*K6*M14(j+1)*M64(j+1))-((Pa-Oa)*Ko*M14(j+1)*O4(j+1))-(mu_1*M14(j+1)));
M24(j+1) = M24(j)+(dt*(K1*M14(j)*M14(j)-K2*M14(j)*M24(j))-(mu_2*M24(j+1))-tmakro1-tmakro2-dtdab);
M34(j+1) = M34(j)+(dt*(K2*M14(j)*M24(j)-K3*M14(j)*M34(j))-mu_3*M34(j));
M44(j+1) = M44(j)+(dt*(K3*M14(j)*M34(j)-K4*M14(j)*M44(j))-mu_4*M44(j));
M54(j+1) = M54(j)+(dt*(K4*M14(j)*M44(j)-K5*M14(j)*M54(j))-mu_5*M54(j));
M64(j+1) = M64(j)+(dt*(K5*M14(j)*M54(j)-K6*M14(j)*M64(j))-mu_6*M64(j));
O4(j+1) = O4(j)+(dt*(K6*M14(j)*M64(j)-Ko*M14(j)*O4(j)-mu_o*O4(j)));
P4(j+1) = P4(j)+(dt*(Ko*M14(j)*O4(j)-mu_p*P4(j)));
end
subplot (2,2,1)
plot( T,M12,’r’,T,M1,’k’,T,M14,’b’,’Linewidth’,4)
legend (‘M1 without drugs’,’M1 with microglia’, ‘M1 with drugs’);
%xticks ([60 120 180 240 300 360 420 480 540 600 660 720 780 840 900 960 1020 1080])
xticks ([30 60 90 120 150 180 ])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title (‘M1’)
subplot (2,2,2)
plot(T,M22,’r’,T,M2,’k’,T,M24,’b’,’Linewidth’,4)
legend (‘M2 without drugs’,’M2 with microglia’,’M2 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([ 0 2 4 6 8 10 12 14 16])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title (‘M2’)
subplot (2,2,3)
plot(T,M32,’r’,T,M3,’k’,T,M34,’b’,’Linewidth’,4)
legend (‘M3 without drugs’,’M3 with microglia’,’M3 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.5 1 1.5 2 2.5 3 3.5])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title (‘M3’)
subplot (2,2,4)
plot(T,M42,’r’,T,M4,’k’,T,M44,’b’,’Linewidth’,4)
legend (‘M4 without drugs’,’M4 with microglia’, ‘M4 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.1 0.2 0.3 0.4 0.5])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title (‘M4’)
subplot (2,2,1)
plot(T,M52,’r’,T,M5,’k’,T,M54,’b’,’Linewidth’,4)
legend (‘M5 without drugs’,’M5 with microglia’, ‘M5 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.05 0.1 0.15 0.2])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title ("M5")
subplot (2,2,2)
plot(T,M62,’r’,T,M6,’k’,T,M64,’b’,’Linewidth’,4)
legend (‘M6 without drugs’,’M6 with microglia’,’M6 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.01 0.02 0.03 0.04 ])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title ("M6")
subplot (2,2,3)
plot(T,O2,’r’,T,O,’k’,T,O4,’b’,’Linewidth’,4)
legend (‘O without drugs’,’O with microglia’, ‘O with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.005 0.01 0.015 0.02])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title ("O")
subplot(2,2,4)
plot(T,P2,’r’,T,P,’k’,T,P4,’b’,’Linewidth’,4)
legend (‘P without drugs’,’P microglia’,’P with drugs’);
xticks ([30 60 90 120 150 180 ])
%yticks ([0 2 4 6 8 10 12])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘
(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title ("P") Hello, this is my code for a diseases and I want to know the effect of drugs (blue line) if I stoped from days 30-60 and continue with microglia from days 60-180. It’s use break code or anything else?
clc;clear;
%parameter
delta=50;
gamma=75;
K1=10^-4;
K2=5*10^-4;
K3=10^-3;
K4=5*10^-3;
K5=10^-2;
K6=5*10^-2;
Ko=0.1;
n=6;
Oa=10;
Pa=100;
mu_1=10^-3;
mu_2=10^-3;
mu_3=10^-3;
mu_4=10^-3;
mu_5=10^-3;
mu_6=10^-3;
mu_o=10^-4;
mu_p= 10^-5;
%input for time
t(1)=0;
dt=0.01; %time interval
t=0:dt:180; %time span
%component for microglia
Mg = 0.047;
lambdaMf = 5*10^-2;
Fo = 3.36*10^-11;
KFo = 2.58*10^-11;
lambdaMa = 2.23*10^-2;
Ao = 0.14;
KAo = 10^-7;
beta = 10;
epsilon1 = 0.3333;
epsilon2 = 0.8;
lambdaM1Tb = 6*10^-3;
Tb=10^-6;
KTb = 2.5*10^-7;
makro1 = 0.02;
makro2 = 0.02;
dM1= 0.015;
dM2= 0.015;
tmakro1 = (Mg*(lambdaMf*(Fo/(Fo+KFo))+lambdaMa*(Ao/(Ao+KAo)))*(epsilon1*beta/beta*(epsilon1+epsilon2)))-(lambdaM1Tb*(Tb/(Tb+KTb)*makro1))-(dM1*makro1);
tmakro2 = (Mg*(lambdaMf*(Fo/(Fo+KFo))+lambdaMa*(Ao/(Ao+KAo)))*(epsilon2/beta*(epsilon1+epsilon2)))+(lambdaM1Tb*(Tb/(Tb+KTb))*makro1)-(dM2*makro2);
%component drugs
Abi = 10^-6;
lambdaN = 8*10^-4;
lambdaA = 8*10^-4;
daboM = 2*10^-3;
dabom = 10^-2; %clearance rate by macrophages
makrofag1 = 0;
makrofag2 = 0;
mikro1 = 0.02;
mikro2 = 0.02;
teta = 0.9;
h = 10;
Kaob = 7*10^-3;
AoB = 10^-8;
dtdab = Abi*(dt*(0.14*1.9*10^-4*exp(-1.9*10^-4)))+ (lambdaN*1)+(lambdaA*1)-(dabom*(makrofag1+(teta*makrofag2))+daboM*(mikro1+(teta*mikro2))*(1+h))*(AoB/(AoB+Kaob));
%initial condition with microglia
M1(1)=10;
M2(1)=0;
M3(1)=0;
M4(1)=0;
M5(1)=0;
M6(1)=0;
O(1)=0;
P(1)=0;
%initial condition without drugs
M12(1)=10;
M22(1)=0;
M32(1)=0;
M42(1)=0;
M52(1)=0;
M62(1)=0;
O2(1)=0;
P2(1)=0;
%initial condition with drugs
M14(1)=10;
M24(1)=0;
M34(1)=0;
M44(1)=0;
M54(1)=0;
M64(1)=0;
O4(1)=0;
P4(1)=0;
%empty array with microglia
T=zeros(length(t)+1,1); %empty array for t
M1=zeros(length(t)+1,1); %empty array for M1
M2=zeros(length(t)+1,1); %empty array for M2
M3=zeros(length(t)+1,1); %empty array for M3
M4=zeros(length(t)+1,1); %empty array for M4
M5=zeros(length(t)+1,1); %empty array for M5
M6=zeros(length(t)+1,1); %empty array for M6
O=zeros(length(t)+1,1); %empty array for O
P=zeros(length(t)+1,1); %empty array for P
sumter=K2*M2+K3*M3+K4*M4+K5*M5;
%empty array without drugs
M12=zeros(length(t)+1,1); %empty array for M1
M22=zeros(length(t)+1,1); %empty array for M2
M32=zeros(length(t)+1,1); %empty array for M3
M42=zeros(length(t)+1,1); %empty array for M4
M52=zeros(length(t)+1,1); %empty array for M5
M62=zeros(length(t)+1,1); %empty array for M6
O2=zeros(length(t)+1,1); %empty array for O
P2=zeros(length(t)+1,1); %empty array for P
sumter2=K2*M22+K3*M32+K4*M42+K5*M52;
%empty array with drugs depend time
M14=zeros(length(t)+1,1); %empty array for M1
M24=zeros(length(t)+1,1); %empty array for M2
M34=zeros(length(t)+1,1); %empty array for M3
M44=zeros(length(t)+1,1); %empty array for M4
M54=zeros(length(t)+1,1); %empty array for M5
M64=zeros(length(t)+1,1); %empty array for M6
O4=zeros(length(t)+1,1); %empty array for O
P4=zeros(length(t)+1,1); %empty array for P
sumter2=K2*M24+K4*M34+K4*M44+K5*M54;
for j = 1:length(t)
%with microglia
T(j+1)=T(j)+dt;
M1(j+1)=M1(j)+1./(1+exp(-T(j)));
M1(j+1) = M1(j)+(dt*(delta*M1(j+1)*(1-(M1(j+1)/gamma))-2*K1*M1(j+1)*M1(j+1)-M1(j+1)*sumter(j+1))-((Oa-n)*K6*M1(j+1)*M6(j+1))-((Pa-Oa)*Ko*M1(j+1)*O(j+1))-(mu_1*M1(j+1)));
M2(j+1) = M2(j)+(dt*(K1*M1(j)*M1(j)-K2*M1(j)*M2(j))-(mu_2*M2(j+1))-tmakro1-tmakro2);
M3(j+1) = M3(j)+(dt*(K2*M1(j)*M2(j)-K3*M1(j)*M3(j))-mu_3*M3(j));
M4(j+1) = M4(j)+(dt*(K3*M1(j)*M3(j)-K4*M1(j)*M4(j))-mu_4*M4(j));
M5(j+1) = M5(j)+(dt*(K4*M1(j)*M4(j)-K5*M1(j)*M5(j))-mu_5*M5(j));
M6(j+1) = M6(j)+(dt*(K5*M1(j)*M5(j)-K6*M1(j)*M6(j))-mu_6*M6(j));
O(j+1) = O(j)+(dt*(K6*M1(j)*M6(j)-Ko*M1(j)*O(j)-mu_o*O(j)));
P(j+1) = P(j)+(dt*(Ko*M1(j)*O(j)-mu_p*P(j)));
%without drugs
T(j+1)=T(j)+dt;
M12(j+1) = M12(j)+1./(1+exp(-T(j)));
M12(j+1) = M12(j)+(dt*(delta*M12(j+1)*(1-(M12(j+1)/gamma))-2*K1*M12(j+1)*M12(j+1)-M12(j+1)*sumter2(j+1))-((Oa-n)*K6*M12(j+1)*M62(j+1))-((Pa-Oa)*Ko*M12(j+1)*O2(j+1))-(mu_1*M12(j+1)));
M22(j+1) = M22(j)+(dt*(K1*M12(j)*M12(j)-K2*M12(j)*M22(j))-(mu_2*M22(j+1)));
M32(j+1) = M32(j)+(dt*(K2*M12(j)*M22(j)-K3*M12(j)*M32(j))-mu_3*M32(j));
M42(j+1) = M42(j)+(dt*(K3*M12(j)*M32(j)-K4*M12(j)*M42(j))-mu_4*M42(j));
M52(j+1) = M52(j)+(dt*(K4*M12(j)*M42(j)-K5*M12(j)*M52(j))-mu_5*M52(j));
M62(j+1) = M62(j)+(dt*(K5*M12(j)*M52(j)-K6*M12(j)*M62(j))-mu_6*M62(j));
O2(j+1) = O2(j)+(dt*(K6*M12(j)*M62(j)-Ko*M12(j)*O2(j)-mu_o*O2(j)));
P2(j+1) = P2(j)+(dt*(Ko*M12(j)*O2(j)-mu_p*P2(j)));
%with drugs depend by time
T(j+1)=T(j)+dt;
M14(j+1) = M14(j)+1./(1+exp(-T(j)));
M14(j+1) = M14(j)+(dt*(delta*M14(j+1)*(1-(M14(j+1)/gamma))-2*K1*M14(j+1)*M14(j+1)-M14(j+1)*sumter2(j+1))-((Oa-n)*K6*M14(j+1)*M64(j+1))-((Pa-Oa)*Ko*M14(j+1)*O4(j+1))-(mu_1*M14(j+1)));
M24(j+1) = M24(j)+(dt*(K1*M14(j)*M14(j)-K2*M14(j)*M24(j))-(mu_2*M24(j+1))-tmakro1-tmakro2-dtdab);
M34(j+1) = M34(j)+(dt*(K2*M14(j)*M24(j)-K3*M14(j)*M34(j))-mu_3*M34(j));
M44(j+1) = M44(j)+(dt*(K3*M14(j)*M34(j)-K4*M14(j)*M44(j))-mu_4*M44(j));
M54(j+1) = M54(j)+(dt*(K4*M14(j)*M44(j)-K5*M14(j)*M54(j))-mu_5*M54(j));
M64(j+1) = M64(j)+(dt*(K5*M14(j)*M54(j)-K6*M14(j)*M64(j))-mu_6*M64(j));
O4(j+1) = O4(j)+(dt*(K6*M14(j)*M64(j)-Ko*M14(j)*O4(j)-mu_o*O4(j)));
P4(j+1) = P4(j)+(dt*(Ko*M14(j)*O4(j)-mu_p*P4(j)));
end
subplot (2,2,1)
plot( T,M12,’r’,T,M1,’k’,T,M14,’b’,’Linewidth’,4)
legend (‘M1 without drugs’,’M1 with microglia’, ‘M1 with drugs’);
%xticks ([60 120 180 240 300 360 420 480 540 600 660 720 780 840 900 960 1020 1080])
xticks ([30 60 90 120 150 180 ])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title (‘M1’)
subplot (2,2,2)
plot(T,M22,’r’,T,M2,’k’,T,M24,’b’,’Linewidth’,4)
legend (‘M2 without drugs’,’M2 with microglia’,’M2 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([ 0 2 4 6 8 10 12 14 16])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title (‘M2’)
subplot (2,2,3)
plot(T,M32,’r’,T,M3,’k’,T,M34,’b’,’Linewidth’,4)
legend (‘M3 without drugs’,’M3 with microglia’,’M3 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.5 1 1.5 2 2.5 3 3.5])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title (‘M3’)
subplot (2,2,4)
plot(T,M42,’r’,T,M4,’k’,T,M44,’b’,’Linewidth’,4)
legend (‘M4 without drugs’,’M4 with microglia’, ‘M4 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.1 0.2 0.3 0.4 0.5])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title (‘M4’)
subplot (2,2,1)
plot(T,M52,’r’,T,M5,’k’,T,M54,’b’,’Linewidth’,4)
legend (‘M5 without drugs’,’M5 with microglia’, ‘M5 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.05 0.1 0.15 0.2])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title ("M5")
subplot (2,2,2)
plot(T,M62,’r’,T,M6,’k’,T,M64,’b’,’Linewidth’,4)
legend (‘M6 without drugs’,’M6 with microglia’,’M6 with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.01 0.02 0.03 0.04 ])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title ("M6")
subplot (2,2,3)
plot(T,O2,’r’,T,O,’k’,T,O4,’b’,’Linewidth’,4)
legend (‘O without drugs’,’O with microglia’, ‘O with drugs’);
xticks ([30 60 90 120 150 180 ])
yticks ([0 0.005 0.01 0.015 0.02])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title ("O")
subplot(2,2,4)
plot(T,P2,’r’,T,P,’k’,T,P4,’b’,’Linewidth’,4)
legend (‘P without drugs’,’P microglia’,’P with drugs’);
xticks ([30 60 90 120 150 180 ])
%yticks ([0 2 4 6 8 10 12])
xlabel(‘days’,’Fontsize’,14,’FontWeight’,’bold’)
ylabel(‘
(g/mL)’,’Fontsize’,14,’FontWeight’,’bold’)
title ("P") matlab, euler, drugs MATLAB Answers — New Questions
Add individual legends to plots in a tiledlayout
Hi,
I would like to create a tiled layout with both a tile-specific and a common legend.
The tile-specific legend should contain a reference to the data contained only on the tile, whereas the common legend should refer to data across all tiles.
Here is a simple code to illustrate what I’m trying to do. The tile legends should refer to the yline and the common legend at the bottom should refer to data in all plots. Hopefully this makes sense.
Can anybody help?
Thank you
x = linspace(0,30);
y1 = sin(x);
y2 = sin(x);
figure
tiledlayout(1,2)
ax1 = nexttile(1);
plot(x,y1)
yline(0,’–‘)
legend(ax1, ”, ‘y=0’)
ax2 = nexttile(2);
plot(x,y2)
yline(0.5,’–‘)
legend(ax2, ”, ‘y=0.5’)
leg = legend(‘sin(x)’);
leg.Layout.Tile = ‘south’;Hi,
I would like to create a tiled layout with both a tile-specific and a common legend.
The tile-specific legend should contain a reference to the data contained only on the tile, whereas the common legend should refer to data across all tiles.
Here is a simple code to illustrate what I’m trying to do. The tile legends should refer to the yline and the common legend at the bottom should refer to data in all plots. Hopefully this makes sense.
Can anybody help?
Thank you
x = linspace(0,30);
y1 = sin(x);
y2 = sin(x);
figure
tiledlayout(1,2)
ax1 = nexttile(1);
plot(x,y1)
yline(0,’–‘)
legend(ax1, ”, ‘y=0’)
ax2 = nexttile(2);
plot(x,y2)
yline(0.5,’–‘)
legend(ax2, ”, ‘y=0.5’)
leg = legend(‘sin(x)’);
leg.Layout.Tile = ‘south’; Hi,
I would like to create a tiled layout with both a tile-specific and a common legend.
The tile-specific legend should contain a reference to the data contained only on the tile, whereas the common legend should refer to data across all tiles.
Here is a simple code to illustrate what I’m trying to do. The tile legends should refer to the yline and the common legend at the bottom should refer to data in all plots. Hopefully this makes sense.
Can anybody help?
Thank you
x = linspace(0,30);
y1 = sin(x);
y2 = sin(x);
figure
tiledlayout(1,2)
ax1 = nexttile(1);
plot(x,y1)
yline(0,’–‘)
legend(ax1, ”, ‘y=0’)
ax2 = nexttile(2);
plot(x,y2)
yline(0.5,’–‘)
legend(ax2, ”, ‘y=0.5’)
leg = legend(‘sin(x)’);
leg.Layout.Tile = ‘south’; tiled layout MATLAB Answers — New Questions
Replacing onmicrosoft
Hello – I recently purchased and installed Office 365 E3 (work or school) licenses for my consulting practice and a friend, client, and fellow small business owner. We would both prefer to use our legacy email address removed for privacy reasons address as our primary username, Outlook email & Calendars instead of the name@domain.onmicrosoft.com configuration assigned while creating the E3 accounts.
I am a domain admin for both accounts and understand it may require editing DNS records.
I would like to configure my own account and test the functionality on both Windows PC AND Mac devices before making similar changes for my client. Can someone please point me to the appropriate resource for getting this done quickly and effectively with minimal disruption.
Thank you.
Hello – I recently purchased and installed Office 365 E3 (work or school) licenses for my consulting practice and a friend, client, and fellow small business owner. We would both prefer to use our legacy email address removed for privacy reasons address as our primary username, Outlook email & Calendars instead of the name@domain.onmicrosoft.com configuration assigned while creating the E3 accounts. I am a domain admin for both accounts and understand it may require editing DNS records. I would like to configure my own account and test the functionality on both Windows PC AND Mac devices before making similar changes for my client. Can someone please point me to the appropriate resource for getting this done quickly and effectively with minimal disruption. Thank you. Read More
Add a border to a page in Word for iPad
Exciting Update, Microsoft 365 Insiders!
Word for iPad now offers a Page Border feature that brings a new level of polish to your documents. With the latest update (Version 2.76 Build 23073006), you can:
Enhance Document Appearance: Add professional-looking borders to reports, essays, and presentations that improve readability and help engage your audience.
Customize with Ease: Employ user-friendly tools to fine-tune the border’s thickness, color, and style to make your document stand out.
Responsive Design: Add borders that adapt to various document sizes and orientations, maintaining a consistent and visually appealing look across all your projects.
Learn how it works in our latest blog: Add a border to a page in Word for iPad
Have a great weekend!
Perry Sjogren
Microsoft 365 Insider Social Media Manager
Become a Microsoft 365 Insider and gain exclusive access to new features and help shape the future of Microsoft 365. Join Now: Windows | Mac | iOS | Android
Exciting Update, Microsoft 365 Insiders!
Word for iPad now offers a Page Border feature that brings a new level of polish to your documents. With the latest update (Version 2.76 Build 23073006), you can:
Enhance Document Appearance: Add professional-looking borders to reports, essays, and presentations that improve readability and help engage your audience.
Customize with Ease: Employ user-friendly tools to fine-tune the border’s thickness, color, and style to make your document stand out.
Responsive Design: Add borders that adapt to various document sizes and orientations, maintaining a consistent and visually appealing look across all your projects.
Learn how it works in our latest blog: Add a border to a page in Word for iPad
Have a great weekend!
Perry Sjogren
Microsoft 365 Insider Social Media Manager
Become a Microsoft 365 Insider and gain exclusive access to new features and help shape the future of Microsoft 365. Join Now: Windows | Mac | iOS | Android
Read More
Dev Channel update to 126.0.2578.1 is live.
Welcome back! We released 126.0.2578.1 to the Dev channel! This includes numerous fixes. For more details on the changes, check out the highlights below.
Added Features:
Implemented a close button to halt media playback.
Improved Reliability:
Fixed an issue that was causing the browser to crash upon playing the next media file.
Fixed an issue that caused the browser to crash when selecting ‘Permissions and Privacy’ from any application in the sidebar.
Resolved a problem where browser would crash upon launch.
Resolved a problem where clicking the ‘x’ button on the privacy page caused browser to crash.
Changed Behavior:
Resolved an issue when triggering the ‘No thanks’ button in the profile pane resulted in the loss of keyboard focus.
Fixed an issue by making the circle selection option more prominent under the ‘Send diagnostic data to Microsoft’ section during feedback submission.
Fixed an issue where the notification pop-up window was not easily locatable.
Resolved an issue where the suggestions for Work and History were still appearing even after using the backspace key.
Fixed an issue where the Scroll View did not refresh when expanding a group within vertical tabs.
Fixed an issue that caused an error to appear in the translation pop-up menu after choosing ‘Always translate xx’ and changing to the desired language.
Fixed an issue where the background color of the text input box in the Favorites hub was not uniform.
iOS:
Resolved a problem where switching tabs would inadvertently change the browser to dark mode, which would persist until the browser was restarted.
Fixed an issue that caused the privacy icon in the search box to be misaligned on iOS devices.
See an issue that you think might be a bug? Remember to send that directly through the in-app feedback by heading to the … menu > Help and feedback > Send feedback and include diagnostics so the team can investigate.
Thanks again for sending us feedback and helping us improve our Insider builds.
~Gouri
Welcome back! We released 126.0.2578.1 to the Dev channel! This includes numerous fixes. For more details on the changes, check out the highlights below.
Microsoft and LinkedIn release the 2024 Work Trend Index on the state of AI at work – The Official Microsoft Blog
Added Features:
Implemented a close button to halt media playback.
Improved Reliability:
Fixed an issue that was causing the browser to crash upon playing the next media file.
Fixed an issue that caused the browser to crash when selecting ‘Permissions and Privacy’ from any application in the sidebar.
Resolved a problem where browser would crash upon launch.
Resolved a problem where clicking the ‘x’ button on the privacy page caused browser to crash.
Changed Behavior:
Resolved an issue when triggering the ‘No thanks’ button in the profile pane resulted in the loss of keyboard focus.
Fixed an issue by making the circle selection option more prominent under the ‘Send diagnostic data to Microsoft’ section during feedback submission.
Fixed an issue where the notification pop-up window was not easily locatable.
Resolved an issue where the suggestions for Work and History were still appearing even after using the backspace key.
Fixed an issue where the Scroll View did not refresh when expanding a group within vertical tabs.
Fixed an issue that caused an error to appear in the translation pop-up menu after choosing ‘Always translate xx’ and changing to the desired language.
Fixed an issue where the background color of the text input box in the Favorites hub was not uniform.
iOS:
Resolved a problem where switching tabs would inadvertently change the browser to dark mode, which would persist until the browser was restarted.
Fixed an issue that caused the privacy icon in the search box to be misaligned on iOS devices.
See an issue that you think might be a bug? Remember to send that directly through the in-app feedback by heading to the … menu > Help and feedback > Send feedback and include diagnostics so the team can investigate.
Thanks again for sending us feedback and helping us improve our Insider builds.
~Gouri Read More
Filter Issue
Dear Experts,
Greetings!
I have an issue where I need to prepare a set from input sheet to Output sheet,
In the “Input” sheet we have New Antenna Id, which can be 1,3,4,7 and each of them has a corresponding RSRP for each set( as shown as an example in Yellow, orange etc)
From this , need to create the Output, so that each Antenna Id 1/3/4/7 has their RSRP values in 4 different columns as shown below:-
Both Legacy(Excel formulae) and PQ solutions are welcome.
Thanks & Regards
Anupam
Dear Experts, Greetings!I have an issue where I need to prepare a set from input sheet to Output sheet,In the “Input” sheet we have New Antenna Id, which can be 1,3,4,7 and each of them has a corresponding RSRP for each set( as shown as an example in Yellow, orange etc)From this , need to create the Output, so that each Antenna Id 1/3/4/7 has their RSRP values in 4 different columns as shown below:- Both Legacy(Excel formulae) and PQ solutions are welcome. Thanks & RegardsAnupam Read More
Security consideration of Azure OpenAI with Retrieval Augmented Generative pattern (part 1 of 3)
The Retrieval Augmented Generative (RAG) pattern is a novel approach that combines neural text generation with information retrieval. It allows the generation of natural language responses that are relevant, coherent, and informative, by retrieving and conditioning on relevant documents from a large corpus. RAG pattern has several benefits for the health care industry, such as:
It can produce precise and concise summaries of patient symptoms, medical history, and test results.
It can enhance the communication and education of health care professionals and patients, by generating personalized and engaging responses to their queries, based on the retrieval of authoritative and trustworthy sources.
It can facilitate the innovation and discovery of new treatments and therapies, by generating novel and creative hypotheses, based on the retrieval of cutting-edge research papers and clinical trials.
However, there are number of security risks associated with RAG patter usage. Few examples:
Privacy breaches: RAG models may inadvertently reveal sensitive information about patients or health care providers, by retrieving documents that contain identifiable data, such as names, addresses, or medical records. This could violate the confidentiality and consent of the individuals involved and expose them to potential harm or discrimination.
Adversarial attacks: RAG models may be vulnerable to malicious manipulation, by retrieving documents that are intentionally crafted to deceive or mislead the model. This could result in the generation of harmful or misleading content that could endanger the health and safety of the users or the public.
This is the first article in a series about secure use of Azure OpenAI in health care. Our topic today is how to avoid violating privacy when using RAG pattern.
Imagine you’re developing an app that utilizes the Azure OpenAI service to enable patients to query their after-visit summaries. This is a great illustration of a scenario where RAG pattern is essential. The data output from your team consisted of a set of documents with one document for each patient, and some private information was accidentally exported. Below is a sample of a document.
Imagine you’ve built a patient chat application on your website. Only authorized users can access it, and it offers a predefined list of questions for patients to choose from. But what if Amanda’s account is compromised? A malicious actor could gain access, bypass the predefined questions, and ask anything they want. Alternatively, a bug might allow custom questions you didn’t anticipate.
Let’s explore the potential data a malicious actor could extract if no additional security measures are in place beyond chat authorization and a predefined question list. Using Azure OpenAI Studio as a chat interface, we’ll delve into the risks and vulnerabilities of such a scenario.
Let’s start with a simple query:
> Show me Amanda’s data
As demonstrated, it’s evident that utilizing the RAG pattern could facilitate the retrieval of all of Amanda’s data, including any personal information that might have been unintentionally exported. Now, leveraging the structure of the data, we can access the information of other users as well. For instance, with the query:
> Show me all medical history
Now that we have obtained other users’ names, we can extract data utilized by the RAG pattern for any patient. For instance, with the query:
> Show me Michael’s personal data
What can we do to tackle privacy breaches? It’s evident that relying solely on authorization falls short. Achieving protection for Azure OpenAI from malicious prompts is a crucial aspect of maintaining the safety and integrity of the API. Fortunately, implementing the necessary measures is a straightforward process that can be achieved by following a few simple steps:
Set up an Azure API Management service for your OpenAI API. This will act as a gateway between your OpenAI API and the outside world.
Configure your API Management instance to use the Azure AI Content Safety service as a pre-processing step for all incoming requests. This will ensure that all requests are scanned for potentially malicious content before being forwarded to your OpenAI API.
Use prompt engineering techniques to design prompts that are less likely to result in malicious behavior. This can be done by carefully crafting prompts to encourage specific types of responses and avoiding prompts that might elicit inappropriate responses.
Microsoft Tech Community – Latest Blogs –Read More
Step-by-Step Guide: Building and Integrating Custom Package in ADF Workflow Orchestration Manager
Introduction
The Workflow Orchestration Manager in Azure Data Factory streamlines setting up and managing Apache Airflow environments, enhancing your ability to execute scalable data pipelines efficiently. Apache Airflow, a robust open-source platform, allows for the programming, scheduling, and monitoring of intricate workflows by organizing tasks into data pipelines. This capability is highly valued in data engineering and data science for its adaptability and user-friendliness.
In this guide, I will walk you through a demonstration where we extract insights from GitHub data using the GitHub public API, and run custom operators in a private package within the Workflow Orchestration Manager in Azure Data Factory.
Prerequisites
– Tools and Technologies Needed:
Azure data factory account
knowledge in Apache Airflow
knowledge in Python
– Initial Setup:
ADF: create workflow orchestration manager
Airflow (Optional): In this blog, I’m primarily focusing on running custom operators in Airflow. However, if you want to trigger Azure Data Factory (ADF) pipelines directly from Airflow, you’ll need to establish a connection within the Airflow UI. This setup enables the triggering of ADF pipelines from Airflow, for more details click here.
Table of Contents:
Designing Your Custom Package
Create Custom Package
Building Airflow DAG
Run DAG in ADF Data orchestration manager
Logs And Monitoring
Links
Call-To-Action
Step 1: Designing Your Custom Package
In this tutorial, I am utilizing the GitHub API and have written two Python operators: `GitHubAPIReaderOperator` and `CountLanguagesOperator`. These operators are designed to fetch data from GitHub repositories and count the programming languages used, respectively.
from airflow.models import BaseOperator
from airflow.utils.decorators import apply_defaults
import requests
import logging
import re
class GitHubAPIReaderOperator(BaseOperator):
@apply_defaults
def __init__(self, api_url, max_pages=20, token=None, *args, **kwargs):
super(GitHubAPIReaderOperator, self).__init__(*args, **kwargs)
self.api_url = api_url
self.max_pages = max_pages
self.token = token
def execute(self, context):
headers = {“Accept”: “application/vnd.github.v3+json”}
if self.token:
headers[“Authorization”] = f”Bearer {self.token}”
session = requests.Session()
session.headers.update(headers)
next_url = self.api_url
all_data = []
page_count = 0
while next_url and page_count < self.max_pages:
response = session.get(next_url)
response.raise_for_status()
data = response.json()
all_data.extend(data)
next_url = self.get_next_link(response.headers.get(‘Link’))
page_count += 1
return all_data
def get_next_link(self, link_header):
if link_header:
links = link_header.split(‘,’)
next_link = [link for link in links if ‘rel=”next”‘ in link]
if next_link:
match = re.search(r'<(.*)>’, next_link[0])
if match:
return match.group(1)
return None
class CountLanguagesOperator(BaseOperator):
@apply_defaults
def __init__(self, api_url, token=None, *args, **kwargs):
super(CountLanguagesOperator, self).__init__(*args, **kwargs)
self.api_url = api_url
self.token = token
def execute(self, context):
repos = context[‘task_instance’].xcom_pull(task_ids=’fetch_github_data’)
headers = {“Accept”: “application/vnd.github.v3+json”}
if self.token:
headers[“Authorization”] = f”Bearer {self.token}”
session = requests.Session()
session.headers.update(headers)
language_counts = {}
for repo in repos:
languages_url = repo.get(‘languages_url’)
if not languages_url:
continue # Skip repos without a languages URL
try:
response = session.get(languages_url)
response.raise_for_status()
languages_data = response.json()
for language in languages_data.keys():
if language in language_counts:
language_counts[language] += 1
else:
language_counts[language] = 1
except requests.exceptions.HTTPError as error:
if error.response.status_code == 403:
logging.warning(f”Skipping repository due to HTTP 403 Forbidden: {languages_url}”)
continue
else:
raise
# Output the results
for lang, count in language_counts.items():
logging.info(f”{lang} repositories count: {count}”)
return language_counts
Please check API‘s documentation and limitations.
Step 2: Create the Custom Package
Follow steps below to create wheel package in Python
you have to have folder hierarchy:
in the setup file add the package folder name like so:
from setuptools import setup, find_packages
setup(
name=”custom_operators”,
version=”0.1.0″,
package_dir={“”: “src”},
packages=find_packages(where=”src”),
install_requires=[
# List your dependencies here, e.g., ‘numpy’, ‘pandas’
],
classifiers=[
“Programming Language :: Python :: 3”,
“License :: OSI Approved :: MIT License”,
“Operating System :: OS Independent”,
],
python_requires=’>=3.6′,
)
in CMD, run this command to create the wheel package:
pip install setuptools wheelpython setup.py sdist bdist_wheel
This command will create a source distribution and a wheel for your package. The wheel file (.whl) will be stored in a newly created dist/ directory under custom_operators folder.
Step 3: Building Airflow DAG
Now that we have build our custom operators and created the wheel package, now we need to create a dag that will trigger these operators.
for that i created 2 tasks, fetch_github_data and count_languages.
each will call the operators above
from airflow import DAG
from datetime import datetime, timedelta
from custom_operators.github_operators import GitHubAPIReaderOperator,CountLanguagesOperator
default_args = {
‘owner’: ‘airflow’,
‘start_date’: datetime(2023, 1, 1),
‘depends_on_past’: False,
’email_on_failure’: False,
’email_on_retry’: False,
‘retries’: 1,
‘retry_delay’: timedelta(minutes=5),
}
dag = DAG(
‘github_language_analysis’,
default_args=default_args,
description=’Analyze GitHub repos for language usage’,
schedule_interval=timedelta(days=1),
)
fetch_github_data = GitHubAPIReaderOperator(
task_id=’fetch_github_data’,
api_url=’https://api.github.com/repositories’,
max_pages=10,
token=’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’, # Replace with your actual token
dag=dag
)
count_languages = CountLanguagesOperator(
task_id=’count_languages’,
api_url=’https://api.github.com’,
token=’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’, # Replace with your actual token
dag=dag
)
fetch_github_data >> count_languages
Step 4: Run DAG in ADF Data orchestration manager
Now, we built our DAG and our custom package.
in order to run it in ADF.
1. Create managed Airflow instance in ADF following MS docs.
2. in ADLS workspace, create the folder hierarchy as the following:
In the requirements file, include the path to the custom package stored in your ADLS storage account as follows:
/opt/airflow/dags/custom_operators-0.1.0-py3-none-any.whl
3. In the ADF workspace, click on “Import files.” Navigate to your ADLS storage account, locate the “Airflow” folder, and check the “Import requirements” checkbox.
it will take a few minutes till ADF orchestration manager will update the code and the custom package.
Step 5: Logs and Monitoring
After importing the files, click on the “Monitor” button in the Data Orchestration Manager to view task execution and export Airflow logs. This will open the Airflow UI.
DAG:
Logs in count_languages task :
P.S: For more dynamic work, you can save the languages count as a JSON file and store it in your storage account.
Links:
Install a Private package – Azure Data Factory | Microsoft Learn
How does Workflow Orchestration Manager work? – Azure Data Factory | Microsoft Learn
airflow.operators.python — Airflow Documentation (apache.org)
airflow.providers.microsoft.azure — apache-airflow-providers-microsoft-azure Documentation
Call to Action:
– Make sure to establish all connections before starting to work on managed airflow.
– check MS documentation on Workflow Orchestration Manager.
– Please help us improve by sharing your valuable Workflow Orchestration Manager Preview feedback by emailing us at ManagedAirflow@microsoft.com
– Follow me on LinkedIn: Sally Dabbah | LinkedIn
Microsoft Tech Community – Latest Blogs –Read More