Category: News
Calculation of centroide of an object in image
Hello everyone
i am currently working on a school project of medical image. I have an x-ray image of a head in lateral position with a brain tumor. i have to calculate the centroide of this tumor. the tumor has an higher contrast however so does other objects in the image. how can i do it?
thank you everyone in advance.
i don’t have much experience with matlab so i am a bit in a struggleHello everyone
i am currently working on a school project of medical image. I have an x-ray image of a head in lateral position with a brain tumor. i have to calculate the centroide of this tumor. the tumor has an higher contrast however so does other objects in the image. how can i do it?
thank you everyone in advance.
i don’t have much experience with matlab so i am a bit in a struggle Hello everyone
i am currently working on a school project of medical image. I have an x-ray image of a head in lateral position with a brain tumor. i have to calculate the centroide of this tumor. the tumor has an higher contrast however so does other objects in the image. how can i do it?
thank you everyone in advance.
i don’t have much experience with matlab so i am a bit in a struggle medical image, image analysis MATLAB Answers — New Questions
Black screen every few seconds and stuck on desktop forever
Hi,
My Windows 10 PC suddenly goes black every few seconds and stuck on desktop after a recent update. Now, I can’t do anything except ctrl alt dlt.
Hi, My Windows 10 PC suddenly goes black every few seconds and stuck on desktop after a recent update. Now, I can’t do anything except ctrl alt dlt. Read More
How to fuse multiple images while retaining the color of the original images and changing some image colors?
Hello, all,
I am trying to fuse multiple images together to form a final image with the original colors in the original images, however, when I fuse them together, they are mixing and blending the colors to be a completely different color from what I am looking for.
Can I get some insight on solving this please?
Final Image that needs help fixing the colors:
Full map image stored as 600x600x3 uint8:
Fastest path image (the white pixels here need to be green to indicate the fastest path in the final image) stored as 600x600x3 uint8:
Trajectory recorded (the black and magenta pixels) not the exact example from the above images but they are in the same structure:
Stored in workspace as: matImgRGB in a 600×600 uint8 and this is the outcome when using infuse() with the Fastest path image above:
The final image should be the green fastest path image with the colors of the tracjectory recorded overlaid with the full map image with it’s blue color. Appreciate the help!
Many thanks,
MichaelHello, all,
I am trying to fuse multiple images together to form a final image with the original colors in the original images, however, when I fuse them together, they are mixing and blending the colors to be a completely different color from what I am looking for.
Can I get some insight on solving this please?
Final Image that needs help fixing the colors:
Full map image stored as 600x600x3 uint8:
Fastest path image (the white pixels here need to be green to indicate the fastest path in the final image) stored as 600x600x3 uint8:
Trajectory recorded (the black and magenta pixels) not the exact example from the above images but they are in the same structure:
Stored in workspace as: matImgRGB in a 600×600 uint8 and this is the outcome when using infuse() with the Fastest path image above:
The final image should be the green fastest path image with the colors of the tracjectory recorded overlaid with the full map image with it’s blue color. Appreciate the help!
Many thanks,
Michael Hello, all,
I am trying to fuse multiple images together to form a final image with the original colors in the original images, however, when I fuse them together, they are mixing and blending the colors to be a completely different color from what I am looking for.
Can I get some insight on solving this please?
Final Image that needs help fixing the colors:
Full map image stored as 600x600x3 uint8:
Fastest path image (the white pixels here need to be green to indicate the fastest path in the final image) stored as 600x600x3 uint8:
Trajectory recorded (the black and magenta pixels) not the exact example from the above images but they are in the same structure:
Stored in workspace as: matImgRGB in a 600×600 uint8 and this is the outcome when using infuse() with the Fastest path image above:
The final image should be the green fastest path image with the colors of the tracjectory recorded overlaid with the full map image with it’s blue color. Appreciate the help!
Many thanks,
Michael image processing MATLAB Answers — New Questions
How to increase Buffer size parameter in MATLAB .mdl simulation file?
I am having error like "The specified buffer was too small.During simulation, the buffer size was temporarily increased to 2048. In order to use Real-Time Workshop, you need to update the buffer size parameter"I am having error like "The specified buffer was too small.During simulation, the buffer size was temporarily increased to 2048. In order to use Real-Time Workshop, you need to update the buffer size parameter" I am having error like "The specified buffer was too small.During simulation, the buffer size was temporarily increased to 2048. In order to use Real-Time Workshop, you need to update the buffer size parameter" figure, circuit MATLAB Answers — New Questions
Default document not showing while using IIS as a reverse proxy server
I am using IIS as a reverse proxy for multiple applications using URL rewrite module. I have wrote a rule like “App/?(.*)” to match the application path.
The default document which is a “Home.aspx” file is loading when I put a path like “https://localhost/App/” but, if I remove the last forward-slash like “https://localhost/App” it is not working.
I understand that the rule is written to consider only after the slash, but any way I can rewrite the rule to written the default document without the last slash as well ? Kind suggest.
I am using IIS as a reverse proxy for multiple applications using URL rewrite module. I have wrote a rule like “App/?(.*)” to match the application path.The default document which is a “Home.aspx” file is loading when I put a path like “https://localhost/App/” but, if I remove the last forward-slash like “https://localhost/App” it is not working. I understand that the rule is written to consider only after the slash, but any way I can rewrite the rule to written the default document without the last slash as well ? Kind suggest. Read More
Not enough input arguments ode45
Trying to find theta, angular velocity, and angular acceleration.
clear all
close all
clc
syms theta1(t)
%physical constants
Dd=0.1; Dw=0.75; Dh=0.5; Dm=15; ax=0.1; ay=0.5; b=0.25;
a = sqrt(ax^2 + ay^2); Jd = (1/3)*Dm*Dh^2;
Dweight=Dm*9.81;
thetaD0 = 0;
dthetaDdt0=0;
PHI = atand(ax/ay);
Lo = sqrt(a^2 + b^2 -2*a*b*cosd(PHI));
xmax = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+90)) – Lo;
Ltotal = Lo + xmax;
k=500;
numphi = a*sind(PHI + thetaD0);
denphi = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+thetaD0));
phi = asind(numphi/denphi);
d = 0.01;
%motor
NoLoadSpeed = 1057.672; %rad/s
Kt = 0.01386; %Vsec/rad
NoLoadI = 0.036; %A
Cvf = Kt*NoLoadI/NoLoadSpeed;
Jm =4.2E-7; %kg m^2
w = 1.5708/4 ; %rad/s
x = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+theta1)) – Lo;
i=0.036;
[t, sol] = calcsum(thetaD0, dthetaDdt0, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, Jd, Jm)
%sol = [0;0;0]
%derivs = myODE(t, sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD0, Jd, Jm)
%%
function [t, sol] = calcsum(thetaD0, dthetaDdt0, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, Jd, Jm)
sol0 = [thetaD0; dthetaDdt0; i];
tspan = [0, 5];
[t, sol] = ode45(@(t, sol) myODE(sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD0, Jd, Jm), tspan, sol0);
end
%%
function derivs = myODE(t, sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD, Jd, Jm) %calc
dthetaDdt = sol(1);
g = (Kt*i – Cvf*dthetaDdt*(2*pi*b*sind(phi)/d));
num = 2*((2*pi/d)*((Kt*i – Cvf*dthetaDdt*(2*pi*b*sind(phi)/d))) + k*x)*b*sind(phi) – 0.5*Dm*9.81*Dh*sin(thetaD);
h = pi*b*sin(phi)/d;
den = Jd + 8*Jm*h^2;
ddthetaDdt = num/den;
derivs = [dthetaDdt; ddthetaDdt];
endTrying to find theta, angular velocity, and angular acceleration.
clear all
close all
clc
syms theta1(t)
%physical constants
Dd=0.1; Dw=0.75; Dh=0.5; Dm=15; ax=0.1; ay=0.5; b=0.25;
a = sqrt(ax^2 + ay^2); Jd = (1/3)*Dm*Dh^2;
Dweight=Dm*9.81;
thetaD0 = 0;
dthetaDdt0=0;
PHI = atand(ax/ay);
Lo = sqrt(a^2 + b^2 -2*a*b*cosd(PHI));
xmax = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+90)) – Lo;
Ltotal = Lo + xmax;
k=500;
numphi = a*sind(PHI + thetaD0);
denphi = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+thetaD0));
phi = asind(numphi/denphi);
d = 0.01;
%motor
NoLoadSpeed = 1057.672; %rad/s
Kt = 0.01386; %Vsec/rad
NoLoadI = 0.036; %A
Cvf = Kt*NoLoadI/NoLoadSpeed;
Jm =4.2E-7; %kg m^2
w = 1.5708/4 ; %rad/s
x = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+theta1)) – Lo;
i=0.036;
[t, sol] = calcsum(thetaD0, dthetaDdt0, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, Jd, Jm)
%sol = [0;0;0]
%derivs = myODE(t, sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD0, Jd, Jm)
%%
function [t, sol] = calcsum(thetaD0, dthetaDdt0, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, Jd, Jm)
sol0 = [thetaD0; dthetaDdt0; i];
tspan = [0, 5];
[t, sol] = ode45(@(t, sol) myODE(sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD0, Jd, Jm), tspan, sol0);
end
%%
function derivs = myODE(t, sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD, Jd, Jm) %calc
dthetaDdt = sol(1);
g = (Kt*i – Cvf*dthetaDdt*(2*pi*b*sind(phi)/d));
num = 2*((2*pi/d)*((Kt*i – Cvf*dthetaDdt*(2*pi*b*sind(phi)/d))) + k*x)*b*sind(phi) – 0.5*Dm*9.81*Dh*sin(thetaD);
h = pi*b*sin(phi)/d;
den = Jd + 8*Jm*h^2;
ddthetaDdt = num/den;
derivs = [dthetaDdt; ddthetaDdt];
end Trying to find theta, angular velocity, and angular acceleration.
clear all
close all
clc
syms theta1(t)
%physical constants
Dd=0.1; Dw=0.75; Dh=0.5; Dm=15; ax=0.1; ay=0.5; b=0.25;
a = sqrt(ax^2 + ay^2); Jd = (1/3)*Dm*Dh^2;
Dweight=Dm*9.81;
thetaD0 = 0;
dthetaDdt0=0;
PHI = atand(ax/ay);
Lo = sqrt(a^2 + b^2 -2*a*b*cosd(PHI));
xmax = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+90)) – Lo;
Ltotal = Lo + xmax;
k=500;
numphi = a*sind(PHI + thetaD0);
denphi = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+thetaD0));
phi = asind(numphi/denphi);
d = 0.01;
%motor
NoLoadSpeed = 1057.672; %rad/s
Kt = 0.01386; %Vsec/rad
NoLoadI = 0.036; %A
Cvf = Kt*NoLoadI/NoLoadSpeed;
Jm =4.2E-7; %kg m^2
w = 1.5708/4 ; %rad/s
x = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+theta1)) – Lo;
i=0.036;
[t, sol] = calcsum(thetaD0, dthetaDdt0, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, Jd, Jm)
%sol = [0;0;0]
%derivs = myODE(t, sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD0, Jd, Jm)
%%
function [t, sol] = calcsum(thetaD0, dthetaDdt0, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, Jd, Jm)
sol0 = [thetaD0; dthetaDdt0; i];
tspan = [0, 5];
[t, sol] = ode45(@(t, sol) myODE(sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD0, Jd, Jm), tspan, sol0);
end
%%
function derivs = myODE(t, sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD, Jd, Jm) %calc
dthetaDdt = sol(1);
g = (Kt*i – Cvf*dthetaDdt*(2*pi*b*sind(phi)/d));
num = 2*((2*pi/d)*((Kt*i – Cvf*dthetaDdt*(2*pi*b*sind(phi)/d))) + k*x)*b*sind(phi) – 0.5*Dm*9.81*Dh*sin(thetaD);
h = pi*b*sin(phi)/d;
den = Jd + 8*Jm*h^2;
ddthetaDdt = num/den;
derivs = [dthetaDdt; ddthetaDdt];
end ode45 MATLAB Answers — New Questions
Visual studio is automatically making errors while building
I have a vb.net project and now whenever i edit the ui elements like change the text of labels importing images or even changing project setting are also making errors in the file HarmonyPlayer.Designer.vb
the errors are like btm_mute.Image = resources.sound i know the correct one is btm_mute.Image = my.resources.sound but whenever i try to run the app after changing the resources these errors automatically made i am providing a clip https://drive.google.com/file/d/1MkMT3nb5EALMrZoXx5Y9IOoGClIbUmUB/view?usp=drive_link
I have a vb.net project and now whenever i edit the ui elements like change the text of labels importing images or even changing project setting are also making errors in the file HarmonyPlayer.Designer.vbthe errors are like btm_mute.Image = resources.sound i know the correct one is btm_mute.Image = my.resources.sound but whenever i try to run the app after changing the resources these errors automatically made i am providing a clip https://drive.google.com/file/d/1MkMT3nb5EALMrZoXx5Y9IOoGClIbUmUB/view?usp=drive_link Read More
Please need help applying EEG seizure detection code on edf files instead of txt
Hello, I’ve been trying to test different available codes to understand how to design an EEG seizure detection algorithm.
I would like to know how to change the code here: https://www.mathworks.com/help/wavelet/ug/time-frequency-convolutional-network-for-eeg-data-classification.html so I can use it fir the CHB MIT data (edf files) instead of txt files from the Bonn data set if possible. The section below in particular:
ds = tabularTextDatastore(dataDir,"IncludeSubfolders",true,"FileExtensions",".txt");
extraTXT = contains(tds.Files,"__MACOSX");
tds.Files(extraTXT) = [];
labels = filenames2labels(tds.Files,"ExtractBetween",[1 1]);
ii = 1;
eegData = cell(numel(labels),1);
while hasdata(tds)
tsTable = read(tds);
ts = tsTable.Var1;
eegData{ii} = reshape(ts,1,[]);
ii = ii+1;
endHello, I’ve been trying to test different available codes to understand how to design an EEG seizure detection algorithm.
I would like to know how to change the code here: https://www.mathworks.com/help/wavelet/ug/time-frequency-convolutional-network-for-eeg-data-classification.html so I can use it fir the CHB MIT data (edf files) instead of txt files from the Bonn data set if possible. The section below in particular:
ds = tabularTextDatastore(dataDir,"IncludeSubfolders",true,"FileExtensions",".txt");
extraTXT = contains(tds.Files,"__MACOSX");
tds.Files(extraTXT) = [];
labels = filenames2labels(tds.Files,"ExtractBetween",[1 1]);
ii = 1;
eegData = cell(numel(labels),1);
while hasdata(tds)
tsTable = read(tds);
ts = tsTable.Var1;
eegData{ii} = reshape(ts,1,[]);
ii = ii+1;
end Hello, I’ve been trying to test different available codes to understand how to design an EEG seizure detection algorithm.
I would like to know how to change the code here: https://www.mathworks.com/help/wavelet/ug/time-frequency-convolutional-network-for-eeg-data-classification.html so I can use it fir the CHB MIT data (edf files) instead of txt files from the Bonn data set if possible. The section below in particular:
ds = tabularTextDatastore(dataDir,"IncludeSubfolders",true,"FileExtensions",".txt");
extraTXT = contains(tds.Files,"__MACOSX");
tds.Files(extraTXT) = [];
labels = filenames2labels(tds.Files,"ExtractBetween",[1 1]);
ii = 1;
eegData = cell(numel(labels),1);
while hasdata(tds)
tsTable = read(tds);
ts = tsTable.Var1;
eegData{ii} = reshape(ts,1,[]);
ii = ii+1;
end deep learning, eeg, eeg detection, edf files, neural network, matlab MATLAB Answers — New Questions
Dutation type doesn’t preserve seconds accuracy
I’ve been working on some time conversion routines and ran into an issue I didn’t expect. Basically, the duration type doesn’t preserve seconds accuracy. This is caused by the fact that the duration type stores the duration as a single variable called millis (i.e., milliseconds) instead of separate d,h,m,ms or h,m,ms. Why this would be coded in that way does not make any sense to me. E.g., because of this you can get issues such as this:
format longg
dt1 = datetime(2000,1,1,0,0,1.2345678912345);
disp(dt1.Second)
dt2 = datetime(2000,1,1);
[~,~,s] = hms(dt1-dt2)
All well and good, the seconds is represented to full precision in the datetime variable, and the precision of the seconds difference is preserved in the subtraction because the datetimes are close to one another. But if they are not:
dt3 = datetime(1900,1,1);
[~,~,s] = hms(dt1-dt3)
You suddenly get a different result because the difference got mashed into a single millis variable and that large days value caused precision loss in the seconds. And simply constructing a duration type from scratch doesn’t solve anything either because of the internal duration storage as a single millis variable. E.g.,
[~,~,s] = hms(duration(0,0,1.2345678912345))
[~,~,s] = hms(duration(1e6,0,1.2345678912345))
I know, I know … "You shouldn’t depend on this level of accuracy in floating point calculations" etc. But that’s not the point. The point is as long as you have a datetime type that stores individual d,h,m,s properties, then IMHO the duration type should follow suit and preserve accuracy in calculations as much as possible to match it. If the duration type stored the data internally as d,h,m,s (or ms or ns) and took care when doing the internal arithmetic, the above differences could be avoided. In fact, since the millis is a private internal variable, I think TMW could still do this in future versions of MATLAB without breaking any user code since there shouldn’t be any user code that accesses the millis property. Any chance of this, TMW?
And speaking of the datetime type, IMHO the internal variable should have been millis or nanos instead of seconds. That way standard Terrestrial Time epochs such as J2000 (January 1, 2000, 11:58:55.816 UTC) etc. could be represented exactly internally. But since datetime y,m,d,h,m,s properties are public this unfortunately can’t be changed now.I’ve been working on some time conversion routines and ran into an issue I didn’t expect. Basically, the duration type doesn’t preserve seconds accuracy. This is caused by the fact that the duration type stores the duration as a single variable called millis (i.e., milliseconds) instead of separate d,h,m,ms or h,m,ms. Why this would be coded in that way does not make any sense to me. E.g., because of this you can get issues such as this:
format longg
dt1 = datetime(2000,1,1,0,0,1.2345678912345);
disp(dt1.Second)
dt2 = datetime(2000,1,1);
[~,~,s] = hms(dt1-dt2)
All well and good, the seconds is represented to full precision in the datetime variable, and the precision of the seconds difference is preserved in the subtraction because the datetimes are close to one another. But if they are not:
dt3 = datetime(1900,1,1);
[~,~,s] = hms(dt1-dt3)
You suddenly get a different result because the difference got mashed into a single millis variable and that large days value caused precision loss in the seconds. And simply constructing a duration type from scratch doesn’t solve anything either because of the internal duration storage as a single millis variable. E.g.,
[~,~,s] = hms(duration(0,0,1.2345678912345))
[~,~,s] = hms(duration(1e6,0,1.2345678912345))
I know, I know … "You shouldn’t depend on this level of accuracy in floating point calculations" etc. But that’s not the point. The point is as long as you have a datetime type that stores individual d,h,m,s properties, then IMHO the duration type should follow suit and preserve accuracy in calculations as much as possible to match it. If the duration type stored the data internally as d,h,m,s (or ms or ns) and took care when doing the internal arithmetic, the above differences could be avoided. In fact, since the millis is a private internal variable, I think TMW could still do this in future versions of MATLAB without breaking any user code since there shouldn’t be any user code that accesses the millis property. Any chance of this, TMW?
And speaking of the datetime type, IMHO the internal variable should have been millis or nanos instead of seconds. That way standard Terrestrial Time epochs such as J2000 (January 1, 2000, 11:58:55.816 UTC) etc. could be represented exactly internally. But since datetime y,m,d,h,m,s properties are public this unfortunately can’t be changed now. I’ve been working on some time conversion routines and ran into an issue I didn’t expect. Basically, the duration type doesn’t preserve seconds accuracy. This is caused by the fact that the duration type stores the duration as a single variable called millis (i.e., milliseconds) instead of separate d,h,m,ms or h,m,ms. Why this would be coded in that way does not make any sense to me. E.g., because of this you can get issues such as this:
format longg
dt1 = datetime(2000,1,1,0,0,1.2345678912345);
disp(dt1.Second)
dt2 = datetime(2000,1,1);
[~,~,s] = hms(dt1-dt2)
All well and good, the seconds is represented to full precision in the datetime variable, and the precision of the seconds difference is preserved in the subtraction because the datetimes are close to one another. But if they are not:
dt3 = datetime(1900,1,1);
[~,~,s] = hms(dt1-dt3)
You suddenly get a different result because the difference got mashed into a single millis variable and that large days value caused precision loss in the seconds. And simply constructing a duration type from scratch doesn’t solve anything either because of the internal duration storage as a single millis variable. E.g.,
[~,~,s] = hms(duration(0,0,1.2345678912345))
[~,~,s] = hms(duration(1e6,0,1.2345678912345))
I know, I know … "You shouldn’t depend on this level of accuracy in floating point calculations" etc. But that’s not the point. The point is as long as you have a datetime type that stores individual d,h,m,s properties, then IMHO the duration type should follow suit and preserve accuracy in calculations as much as possible to match it. If the duration type stored the data internally as d,h,m,s (or ms or ns) and took care when doing the internal arithmetic, the above differences could be avoided. In fact, since the millis is a private internal variable, I think TMW could still do this in future versions of MATLAB without breaking any user code since there shouldn’t be any user code that accesses the millis property. Any chance of this, TMW?
And speaking of the datetime type, IMHO the internal variable should have been millis or nanos instead of seconds. That way standard Terrestrial Time epochs such as J2000 (January 1, 2000, 11:58:55.816 UTC) etc. could be represented exactly internally. But since datetime y,m,d,h,m,s properties are public this unfortunately can’t be changed now. duration, datetime, seconds MATLAB Answers — New Questions
Error due to not enough input arguments in ‘ C_c = cold.m_dot_c*Cold.c_p_c; %W/K ‘
function [ q, e, UA, T_c_o ] = find_UA( hot, cold )
%Determine minimum heat capacity rate
C_c = cold.m_dot_c * cold.c_p_c; %W/K
C_h = hot.m_dot_h * hot.c_p_h; %W/K
C_min = min(C_c, C_h);
C_max = max(C_c, C_h);function [ q, e, UA, T_c_o ] = find_UA( hot, cold )
%Determine minimum heat capacity rate
C_c = cold.m_dot_c * cold.c_p_c; %W/K
C_h = hot.m_dot_h * hot.c_p_h; %W/K
C_min = min(C_c, C_h);
C_max = max(C_c, C_h); function [ q, e, UA, T_c_o ] = find_UA( hot, cold )
%Determine minimum heat capacity rate
C_c = cold.m_dot_c * cold.c_p_c; %W/K
C_h = hot.m_dot_h * hot.c_p_h; %W/K
C_min = min(C_c, C_h);
C_max = max(C_c, C_h); input arguments MATLAB Answers — New Questions
How to modify the response of a antenna element with respect to different opearting frequency in the specified frequency range?
Take the phased.IsotropoicAntennaElement as an example. ‘FrequencyRange’ is set between 1GHz and 2GHz. Under the default cofiguration, the response of the antenna in the specified ‘FrequencyRange’ is a constant of one. I wonder how can I change the respose with respect to different frequency.
antenna = phased.IsotropicAntennaElement(‘FrequencyRange’,[1e9 2e9]);
fc = 1e9*(1:0.1:2);
resp = antenna(fc,[0;0])Take the phased.IsotropoicAntennaElement as an example. ‘FrequencyRange’ is set between 1GHz and 2GHz. Under the default cofiguration, the response of the antenna in the specified ‘FrequencyRange’ is a constant of one. I wonder how can I change the respose with respect to different frequency.
antenna = phased.IsotropicAntennaElement(‘FrequencyRange’,[1e9 2e9]);
fc = 1e9*(1:0.1:2);
resp = antenna(fc,[0;0]) Take the phased.IsotropoicAntennaElement as an example. ‘FrequencyRange’ is set between 1GHz and 2GHz. Under the default cofiguration, the response of the antenna in the specified ‘FrequencyRange’ is a constant of one. I wonder how can I change the respose with respect to different frequency.
antenna = phased.IsotropicAntennaElement(‘FrequencyRange’,[1e9 2e9]);
fc = 1e9*(1:0.1:2);
resp = antenna(fc,[0;0]) antenna response MATLAB Answers — New Questions
phased array antenna simulation
i want to simualte antenna radition pattern of radar rx antenna using 8 element linear antenna (as shown in figure 2).i could able to create the required radiation pattern by placing the antenna element on Y axis(ref figure 1) ,(Matlab code is attached for reference):
%%%%%%%%%START of matlab code for antenna element placing on Y axis %%%%%%%%%%%%%
clc;
clear all;
close all;
%fc = 77e9;
fc = 60e9;
%c = 3e8;
c = physconst(‘LightSpeed’);
lambda = c/fc;
Nt = 2;
Nr = 4;
ang = -90:90;
% % If both arrays have half-wavelength spacing, which are sometimes referred to as full arrays,
% % then the two-way pattern is close to the receive array pattern.
dr = lambda/2;
dt = Nr*(lambda/2);
Vy_pos1 = [0;-lambda;0];
Vy_pos2 = [0;-lambda+(lambda/2);0];
Vy_pos3 = [0;-lambda+ 2*(lambda/2);0];
Vy_pos4 = [0;-lambda+ 3*(lambda/2);0];
Vy_pos5 = [0;-lambda+ 4*(lambda/2);0];
Vy_pos6 = [0;-lambda+ 5*(lambda/2);0];
Vy_pos7 = [0;-lambda+ 6*(lambda/2);0];
Vy_pos8 = [0;-lambda+ 7*(lambda/2);0];
vxarray_4 = phased.ConformalArray(‘ElementPosition’,[Vy_pos1,Vy_pos2,Vy_pos3,Vy_pos4,Vy_pos5,Vy_pos6,Vy_pos7,Vy_pos8]);
figure
viewArray(vxarray_4 ,’ShowIndex’,’All’,’ShowNormal’,true,’Title’,’ conformal virtual array ,aantenna elements placed on Y axis’);
patv_4 = pattern(vxarray_4,fc,ang,0,’Type’,’powerdb’);
figure;
helperPlotMultipledBPattern(ang,[patv_4],[-30 0],…
{‘Two-way Pattern’,’Virtual Array Pattern’},…
‘Patterns of thin/full arrays and virtual array’,…
{‘-‘,’–‘},[1 2]);
%%%%%%%%%End of matlab code for antenna element placing on Y axis %%%%%%%%%%%%%
But my requirement is to achieve the same radaiation pattern by keeping antenna elements placement on X axis insetad of Y axis.please kindly check and confirm on how to realise same pattern by placing antenna element on the X axis(instead of y axis)?
i tried to place antenna elements on X axis and try to plot the resultant pattern but it doesnot meet the my required pattern.
figures and codes of the same are attached for reference.
%%%%%%%%%START of matlab code for antenna element placing on X axis %%%%%%%%%%%%%
clc;
clear all;
close all;
%fc = 77e9;
fc = 60e9;
%c = 3e8;
c = physconst(‘LightSpeed’);
lambda = c/fc;
Nt = 2;
Nr = 4;
ang = -90:90;
% % If both arrays have half-wavelength spacing, which are sometimes referred to as full arrays,
% % then the two-way pattern is close to the receive array pattern.
dr = lambda/2;
dt = Nr*(lambda/2);
Vx_pos1 = [-lambda;0;0];
Vx_pos2 = [-lambda+(lambda/2);0;0];
Vx_pos3 = [-lambda+ 2*(lambda/2);0;0];
Vx_pos4 = [-lambda+ 3*(lambda/2);0;0];
Vx_pos5 = [-lambda+ 4*(lambda/2);0;0];
Vx_pos6 = [-lambda+ 5*(lambda/2);0;0];
Vx_pos7 = [-lambda+ 6*(lambda/2);0;0];
Vx_pos8 = [-lambda+ 7*(lambda/2);0;0];
vxarray_3 = phased.ConformalArray(‘ElementPosition’,[Vx_pos1,Vx_pos2,Vx_pos3,Vx_pos4,Vx_pos5,Vx_pos6,Vx_pos7,Vx_pos8]);
figure
viewArray(vxarray_3 ,’ShowIndex’,’All’,’ShowNormal’,true,’Title’,’ conformal virtual array ,antenna elements placed on X axis’);
patv_3 = pattern(vxarray_3,fc,ang,0,’Type’,’powerdb’);
figure;
helperPlotMultipledBPattern(ang,[patv_3],[-30 0],…
{‘Two-way Pattern’,’Virtual Array Pattern’},…
‘Patterns of thin/full arrays and virtual array’,…
{‘-‘,’–‘},[1 2]);
%%%%%%%%%End of matlab code for antenna element placing on X axis %%%%%%%%%%%%%
please kindly check and confirm on how to realise rquired pattern by placing antenna element on the X axis(instead of y axis)?i want to simualte antenna radition pattern of radar rx antenna using 8 element linear antenna (as shown in figure 2).i could able to create the required radiation pattern by placing the antenna element on Y axis(ref figure 1) ,(Matlab code is attached for reference):
%%%%%%%%%START of matlab code for antenna element placing on Y axis %%%%%%%%%%%%%
clc;
clear all;
close all;
%fc = 77e9;
fc = 60e9;
%c = 3e8;
c = physconst(‘LightSpeed’);
lambda = c/fc;
Nt = 2;
Nr = 4;
ang = -90:90;
% % If both arrays have half-wavelength spacing, which are sometimes referred to as full arrays,
% % then the two-way pattern is close to the receive array pattern.
dr = lambda/2;
dt = Nr*(lambda/2);
Vy_pos1 = [0;-lambda;0];
Vy_pos2 = [0;-lambda+(lambda/2);0];
Vy_pos3 = [0;-lambda+ 2*(lambda/2);0];
Vy_pos4 = [0;-lambda+ 3*(lambda/2);0];
Vy_pos5 = [0;-lambda+ 4*(lambda/2);0];
Vy_pos6 = [0;-lambda+ 5*(lambda/2);0];
Vy_pos7 = [0;-lambda+ 6*(lambda/2);0];
Vy_pos8 = [0;-lambda+ 7*(lambda/2);0];
vxarray_4 = phased.ConformalArray(‘ElementPosition’,[Vy_pos1,Vy_pos2,Vy_pos3,Vy_pos4,Vy_pos5,Vy_pos6,Vy_pos7,Vy_pos8]);
figure
viewArray(vxarray_4 ,’ShowIndex’,’All’,’ShowNormal’,true,’Title’,’ conformal virtual array ,aantenna elements placed on Y axis’);
patv_4 = pattern(vxarray_4,fc,ang,0,’Type’,’powerdb’);
figure;
helperPlotMultipledBPattern(ang,[patv_4],[-30 0],…
{‘Two-way Pattern’,’Virtual Array Pattern’},…
‘Patterns of thin/full arrays and virtual array’,…
{‘-‘,’–‘},[1 2]);
%%%%%%%%%End of matlab code for antenna element placing on Y axis %%%%%%%%%%%%%
But my requirement is to achieve the same radaiation pattern by keeping antenna elements placement on X axis insetad of Y axis.please kindly check and confirm on how to realise same pattern by placing antenna element on the X axis(instead of y axis)?
i tried to place antenna elements on X axis and try to plot the resultant pattern but it doesnot meet the my required pattern.
figures and codes of the same are attached for reference.
%%%%%%%%%START of matlab code for antenna element placing on X axis %%%%%%%%%%%%%
clc;
clear all;
close all;
%fc = 77e9;
fc = 60e9;
%c = 3e8;
c = physconst(‘LightSpeed’);
lambda = c/fc;
Nt = 2;
Nr = 4;
ang = -90:90;
% % If both arrays have half-wavelength spacing, which are sometimes referred to as full arrays,
% % then the two-way pattern is close to the receive array pattern.
dr = lambda/2;
dt = Nr*(lambda/2);
Vx_pos1 = [-lambda;0;0];
Vx_pos2 = [-lambda+(lambda/2);0;0];
Vx_pos3 = [-lambda+ 2*(lambda/2);0;0];
Vx_pos4 = [-lambda+ 3*(lambda/2);0;0];
Vx_pos5 = [-lambda+ 4*(lambda/2);0;0];
Vx_pos6 = [-lambda+ 5*(lambda/2);0;0];
Vx_pos7 = [-lambda+ 6*(lambda/2);0;0];
Vx_pos8 = [-lambda+ 7*(lambda/2);0;0];
vxarray_3 = phased.ConformalArray(‘ElementPosition’,[Vx_pos1,Vx_pos2,Vx_pos3,Vx_pos4,Vx_pos5,Vx_pos6,Vx_pos7,Vx_pos8]);
figure
viewArray(vxarray_3 ,’ShowIndex’,’All’,’ShowNormal’,true,’Title’,’ conformal virtual array ,antenna elements placed on X axis’);
patv_3 = pattern(vxarray_3,fc,ang,0,’Type’,’powerdb’);
figure;
helperPlotMultipledBPattern(ang,[patv_3],[-30 0],…
{‘Two-way Pattern’,’Virtual Array Pattern’},…
‘Patterns of thin/full arrays and virtual array’,…
{‘-‘,’–‘},[1 2]);
%%%%%%%%%End of matlab code for antenna element placing on X axis %%%%%%%%%%%%%
please kindly check and confirm on how to realise rquired pattern by placing antenna element on the X axis(instead of y axis)? i want to simualte antenna radition pattern of radar rx antenna using 8 element linear antenna (as shown in figure 2).i could able to create the required radiation pattern by placing the antenna element on Y axis(ref figure 1) ,(Matlab code is attached for reference):
%%%%%%%%%START of matlab code for antenna element placing on Y axis %%%%%%%%%%%%%
clc;
clear all;
close all;
%fc = 77e9;
fc = 60e9;
%c = 3e8;
c = physconst(‘LightSpeed’);
lambda = c/fc;
Nt = 2;
Nr = 4;
ang = -90:90;
% % If both arrays have half-wavelength spacing, which are sometimes referred to as full arrays,
% % then the two-way pattern is close to the receive array pattern.
dr = lambda/2;
dt = Nr*(lambda/2);
Vy_pos1 = [0;-lambda;0];
Vy_pos2 = [0;-lambda+(lambda/2);0];
Vy_pos3 = [0;-lambda+ 2*(lambda/2);0];
Vy_pos4 = [0;-lambda+ 3*(lambda/2);0];
Vy_pos5 = [0;-lambda+ 4*(lambda/2);0];
Vy_pos6 = [0;-lambda+ 5*(lambda/2);0];
Vy_pos7 = [0;-lambda+ 6*(lambda/2);0];
Vy_pos8 = [0;-lambda+ 7*(lambda/2);0];
vxarray_4 = phased.ConformalArray(‘ElementPosition’,[Vy_pos1,Vy_pos2,Vy_pos3,Vy_pos4,Vy_pos5,Vy_pos6,Vy_pos7,Vy_pos8]);
figure
viewArray(vxarray_4 ,’ShowIndex’,’All’,’ShowNormal’,true,’Title’,’ conformal virtual array ,aantenna elements placed on Y axis’);
patv_4 = pattern(vxarray_4,fc,ang,0,’Type’,’powerdb’);
figure;
helperPlotMultipledBPattern(ang,[patv_4],[-30 0],…
{‘Two-way Pattern’,’Virtual Array Pattern’},…
‘Patterns of thin/full arrays and virtual array’,…
{‘-‘,’–‘},[1 2]);
%%%%%%%%%End of matlab code for antenna element placing on Y axis %%%%%%%%%%%%%
But my requirement is to achieve the same radaiation pattern by keeping antenna elements placement on X axis insetad of Y axis.please kindly check and confirm on how to realise same pattern by placing antenna element on the X axis(instead of y axis)?
i tried to place antenna elements on X axis and try to plot the resultant pattern but it doesnot meet the my required pattern.
figures and codes of the same are attached for reference.
%%%%%%%%%START of matlab code for antenna element placing on X axis %%%%%%%%%%%%%
clc;
clear all;
close all;
%fc = 77e9;
fc = 60e9;
%c = 3e8;
c = physconst(‘LightSpeed’);
lambda = c/fc;
Nt = 2;
Nr = 4;
ang = -90:90;
% % If both arrays have half-wavelength spacing, which are sometimes referred to as full arrays,
% % then the two-way pattern is close to the receive array pattern.
dr = lambda/2;
dt = Nr*(lambda/2);
Vx_pos1 = [-lambda;0;0];
Vx_pos2 = [-lambda+(lambda/2);0;0];
Vx_pos3 = [-lambda+ 2*(lambda/2);0;0];
Vx_pos4 = [-lambda+ 3*(lambda/2);0;0];
Vx_pos5 = [-lambda+ 4*(lambda/2);0;0];
Vx_pos6 = [-lambda+ 5*(lambda/2);0;0];
Vx_pos7 = [-lambda+ 6*(lambda/2);0;0];
Vx_pos8 = [-lambda+ 7*(lambda/2);0;0];
vxarray_3 = phased.ConformalArray(‘ElementPosition’,[Vx_pos1,Vx_pos2,Vx_pos3,Vx_pos4,Vx_pos5,Vx_pos6,Vx_pos7,Vx_pos8]);
figure
viewArray(vxarray_3 ,’ShowIndex’,’All’,’ShowNormal’,true,’Title’,’ conformal virtual array ,antenna elements placed on X axis’);
patv_3 = pattern(vxarray_3,fc,ang,0,’Type’,’powerdb’);
figure;
helperPlotMultipledBPattern(ang,[patv_3],[-30 0],…
{‘Two-way Pattern’,’Virtual Array Pattern’},…
‘Patterns of thin/full arrays and virtual array’,…
{‘-‘,’–‘},[1 2]);
%%%%%%%%%End of matlab code for antenna element placing on X axis %%%%%%%%%%%%%
please kindly check and confirm on how to realise rquired pattern by placing antenna element on the X axis(instead of y axis)? phased array antenna simulation MATLAB Answers — New Questions
Why cannot handle class events run indefinitely?
Suppose there are two objects A and B instantiated from some handle classes.
There is an event in A that B listens to, and an event in B that A listens to.
When the event in A is triggered, B trigger its own event, which in turn triggers the event in A, as demonstrated in the figure.
Theoretically, once the event in A is triggered the program should run indefinitely. However in practice the program terminates when the event in A has been triggered twice. Why?
Take following code snippets for example.
The class definition
classdef myClass < handle
properties
Name
end
events
theEvent
end
methods
function obj = myClass(c)
obj.Name = c;
end
function showName(obj)
disp([‘This is obj ‘, obj.Name])
notify(obj, ‘theEvent’)
end
end
end
The main file to run
A = myClass(‘A’);
B = myClass(‘B’);
addlistener(A, ‘theEvent’, @(varargin)B.showName());
addlistener(B, ‘theEvent’, @(varargin)A.showName());
disp(‘Program started’)
showName(A)
disp(‘Program terminated’)Suppose there are two objects A and B instantiated from some handle classes.
There is an event in A that B listens to, and an event in B that A listens to.
When the event in A is triggered, B trigger its own event, which in turn triggers the event in A, as demonstrated in the figure.
Theoretically, once the event in A is triggered the program should run indefinitely. However in practice the program terminates when the event in A has been triggered twice. Why?
Take following code snippets for example.
The class definition
classdef myClass < handle
properties
Name
end
events
theEvent
end
methods
function obj = myClass(c)
obj.Name = c;
end
function showName(obj)
disp([‘This is obj ‘, obj.Name])
notify(obj, ‘theEvent’)
end
end
end
The main file to run
A = myClass(‘A’);
B = myClass(‘B’);
addlistener(A, ‘theEvent’, @(varargin)B.showName());
addlistener(B, ‘theEvent’, @(varargin)A.showName());
disp(‘Program started’)
showName(A)
disp(‘Program terminated’) Suppose there are two objects A and B instantiated from some handle classes.
There is an event in A that B listens to, and an event in B that A listens to.
When the event in A is triggered, B trigger its own event, which in turn triggers the event in A, as demonstrated in the figure.
Theoretically, once the event in A is triggered the program should run indefinitely. However in practice the program terminates when the event in A has been triggered twice. Why?
Take following code snippets for example.
The class definition
classdef myClass < handle
properties
Name
end
events
theEvent
end
methods
function obj = myClass(c)
obj.Name = c;
end
function showName(obj)
disp([‘This is obj ‘, obj.Name])
notify(obj, ‘theEvent’)
end
end
end
The main file to run
A = myClass(‘A’);
B = myClass(‘B’);
addlistener(A, ‘theEvent’, @(varargin)B.showName());
addlistener(B, ‘theEvent’, @(varargin)A.showName());
disp(‘Program started’)
showName(A)
disp(‘Program terminated’) handle class events, infinite loop, oop MATLAB Answers — New Questions
Channel assignment and carrier aggregation for wifi 6(802.11ax) BER and SNR
I’m trying to make simulations for wifi 6 with channel assignment and carrier aggregation and i need to get BER and SNR values for my simulations i need help. Can you help me to make it and give me some ideas.I’m trying to make simulations for wifi 6 with channel assignment and carrier aggregation and i need to get BER and SNR values for my simulations i need help. Can you help me to make it and give me some ideas. I’m trying to make simulations for wifi 6 with channel assignment and carrier aggregation and i need to get BER and SNR values for my simulations i need help. Can you help me to make it and give me some ideas. 802.11ax, communication, wifi 6, wifi6, channel assignment, carrier aggregation MATLAB Answers — New Questions
“Sorry, this conversation has reached its limit. Let’s start a new chat.”
Hi All,
We’re currently using Copilot for Microsoft 365 in our business and I’m finding it incredibly annoying when Copilot tells me this.
“Sorry, this conversation has reached its limit. Let’s start a new chat.”
When I asked Copilot why, this is what I receive.
“The message “Sorry, this conversation has reached its limit. Let’s start a new chat.” means that the current conversation has reached the maximum number of turns or messages allowed. Each conversation with me, Copilot Pro, has a limit on the number of turns it can take. Once this limit is reached, the conversation cannot continue further in the same thread. Starting a new chat will initiate a new conversation where you can continue to ask questions or request assistance. This is a measure to ensure optimal performance and user experience. I hope this clarifies your query! :smiling_face_with_smiling_eyes:”
“I’m sorry, but I can’t provide the exact number of turns or messages allowed in a conversation. The limit is set to ensure optimal performance and user experience. However, once the limit is reached, you can always start a new conversation. Please let me know if there’s anything else I can assist you with! :smiling_face_with_smiling_eyes:“
I’d love to understand the logic for such a limitation. Can anyone kindly explain this is plain simple English please? Thanks!
Cheers,
Eddie | Zhamatix
Hi All, We’re currently using Copilot for Microsoft 365 in our business and I’m finding it incredibly annoying when Copilot tells me this.”Sorry, this conversation has reached its limit. Let’s start a new chat.”When I asked Copilot why, this is what I receive. “The message “Sorry, this conversation has reached its limit. Let’s start a new chat.” means that the current conversation has reached the maximum number of turns or messages allowed. Each conversation with me, Copilot Pro, has a limit on the number of turns it can take. Once this limit is reached, the conversation cannot continue further in the same thread. Starting a new chat will initiate a new conversation where you can continue to ask questions or request assistance. This is a measure to ensure optimal performance and user experience. I hope this clarifies your query! :smiling_face_with_smiling_eyes:” When I asked Copilot what the limit is, this is what I receive.”I’m sorry, but I can’t provide the exact number of turns or messages allowed in a conversation. The limit is set to ensure optimal performance and user experience. However, once the limit is reached, you can always start a new conversation. Please let me know if there’s anything else I can assist you with! :smiling_face_with_smiling_eyes:”I’d love to understand the logic for such a limitation. Can anyone kindly explain this is plain simple English please? Thanks!Cheers,Eddie | Zhamatix Read More
How to set lower bound lb as a function of optimization variable.
I am solving one optimization using fmincon. Objectives function is a variable of x1,x2,x3.
B= 0; c =[ 0 0.1736 0.0693; 0 0 0.1736]
l_op = 6.3247;
rho = 1.225;
R=37.5; A = pi * R^2;
Z = 8;
n =3;
k= 0.1;
Th = sym(‘Th’, [1, n]);
x = sym(‘x’, [1, n]);
Lam = sym(‘Lam’, [1, n]);
Pt = sym(‘P_opt’, [1, n]);
Per = sym(‘Per’, [1, n]);
z = sym(‘z’, [1, n]);
z(1) = Z;
for i = 1:n
if i > 1
term_sum = 0;
for j = 1:i-1
term_sum = term_sum + ((1 – sqrt(1 – Th(j))) * c(j, i))^2;
end
z(i) = Z * (1 – sqrt(term_sum));
end
Lam(i) = (x(i) * R) / z(i);
Th(i) = (0.000086 * B – 0.0026) * Lam(i)^3 + (-0.0018 * B + 0.0481) * Lam(i)^2 + (0.008 * B – 0.165) * Lam(i) + (-0.0116 * B + 0.3);
Per(i) = 0.22 * (116 / (Lam(i) + 0.08 * B) – 4.06 / (B^3 + 1) – 0.4 * B – 5) * exp(-12.5 / (Lam(i) + 0.08 * B) + 0.4375 / (B^3 + 1));
Pt(i) = 0.5 * rho * A * Per(i) * z(i)^3;
end
objective = -sum(Pt)
Obj = matlabFunction(objective, ‘Vars’, {x});
% Lower and upper bounds
lb = 0.1687 * z(i) % z(i) is a function of x(i) *corrected
ub = 1.6867*ones(1,n);
% Initial guess
x0 = ones(1,n);
% Constraints
Aeq = [];
beq = [];
% Optimization using fmincon
options = optimoptions(‘fmincon’, ‘Display’, ‘iter’, ‘Algorithm’, ‘interior-point’);
% % Optimize the objective function
[x_opt, fval_opt] = fmincon(Obj, x0, [], [], Aeq, beq, lb, ub, [], options);
In my optimization lower bound of the optimization is a function of optimaztion variables. How can I solve it? fmincon can be able to do it or another optimization tools can be chosen?I am solving one optimization using fmincon. Objectives function is a variable of x1,x2,x3.
B= 0; c =[ 0 0.1736 0.0693; 0 0 0.1736]
l_op = 6.3247;
rho = 1.225;
R=37.5; A = pi * R^2;
Z = 8;
n =3;
k= 0.1;
Th = sym(‘Th’, [1, n]);
x = sym(‘x’, [1, n]);
Lam = sym(‘Lam’, [1, n]);
Pt = sym(‘P_opt’, [1, n]);
Per = sym(‘Per’, [1, n]);
z = sym(‘z’, [1, n]);
z(1) = Z;
for i = 1:n
if i > 1
term_sum = 0;
for j = 1:i-1
term_sum = term_sum + ((1 – sqrt(1 – Th(j))) * c(j, i))^2;
end
z(i) = Z * (1 – sqrt(term_sum));
end
Lam(i) = (x(i) * R) / z(i);
Th(i) = (0.000086 * B – 0.0026) * Lam(i)^3 + (-0.0018 * B + 0.0481) * Lam(i)^2 + (0.008 * B – 0.165) * Lam(i) + (-0.0116 * B + 0.3);
Per(i) = 0.22 * (116 / (Lam(i) + 0.08 * B) – 4.06 / (B^3 + 1) – 0.4 * B – 5) * exp(-12.5 / (Lam(i) + 0.08 * B) + 0.4375 / (B^3 + 1));
Pt(i) = 0.5 * rho * A * Per(i) * z(i)^3;
end
objective = -sum(Pt)
Obj = matlabFunction(objective, ‘Vars’, {x});
% Lower and upper bounds
lb = 0.1687 * z(i) % z(i) is a function of x(i) *corrected
ub = 1.6867*ones(1,n);
% Initial guess
x0 = ones(1,n);
% Constraints
Aeq = [];
beq = [];
% Optimization using fmincon
options = optimoptions(‘fmincon’, ‘Display’, ‘iter’, ‘Algorithm’, ‘interior-point’);
% % Optimize the objective function
[x_opt, fval_opt] = fmincon(Obj, x0, [], [], Aeq, beq, lb, ub, [], options);
In my optimization lower bound of the optimization is a function of optimaztion variables. How can I solve it? fmincon can be able to do it or another optimization tools can be chosen? I am solving one optimization using fmincon. Objectives function is a variable of x1,x2,x3.
B= 0; c =[ 0 0.1736 0.0693; 0 0 0.1736]
l_op = 6.3247;
rho = 1.225;
R=37.5; A = pi * R^2;
Z = 8;
n =3;
k= 0.1;
Th = sym(‘Th’, [1, n]);
x = sym(‘x’, [1, n]);
Lam = sym(‘Lam’, [1, n]);
Pt = sym(‘P_opt’, [1, n]);
Per = sym(‘Per’, [1, n]);
z = sym(‘z’, [1, n]);
z(1) = Z;
for i = 1:n
if i > 1
term_sum = 0;
for j = 1:i-1
term_sum = term_sum + ((1 – sqrt(1 – Th(j))) * c(j, i))^2;
end
z(i) = Z * (1 – sqrt(term_sum));
end
Lam(i) = (x(i) * R) / z(i);
Th(i) = (0.000086 * B – 0.0026) * Lam(i)^3 + (-0.0018 * B + 0.0481) * Lam(i)^2 + (0.008 * B – 0.165) * Lam(i) + (-0.0116 * B + 0.3);
Per(i) = 0.22 * (116 / (Lam(i) + 0.08 * B) – 4.06 / (B^3 + 1) – 0.4 * B – 5) * exp(-12.5 / (Lam(i) + 0.08 * B) + 0.4375 / (B^3 + 1));
Pt(i) = 0.5 * rho * A * Per(i) * z(i)^3;
end
objective = -sum(Pt)
Obj = matlabFunction(objective, ‘Vars’, {x});
% Lower and upper bounds
lb = 0.1687 * z(i) % z(i) is a function of x(i) *corrected
ub = 1.6867*ones(1,n);
% Initial guess
x0 = ones(1,n);
% Constraints
Aeq = [];
beq = [];
% Optimization using fmincon
options = optimoptions(‘fmincon’, ‘Display’, ‘iter’, ‘Algorithm’, ‘interior-point’);
% % Optimize the objective function
[x_opt, fval_opt] = fmincon(Obj, x0, [], [], Aeq, beq, lb, ub, [], options);
In my optimization lower bound of the optimization is a function of optimaztion variables. How can I solve it? fmincon can be able to do it or another optimization tools can be chosen? optimization, fmincon, lower bound MATLAB Answers — New Questions
My function doesn’t append to it’s list
%calculates polynomials of form Pk = ((2k-1)t/k)*Pk-1 – ((k-1)/k)*Pk-2
function [poly, filllist] = calc_poly (n, t, filllist)
if n == 0
filllist = [filllist; ones(size(t))];
poly = ones(size(t));
return
end
if n == 1
filllist = [filllist; t];
poly = t;
return
end
poly = ((2*n-1)/n)*t.*calc_poly(n-1, t, filllist) – ((n-1)/n)*calc_poly(n-2, t, filllist);
filllist = [filllist; poly];
end
This function is supposed to recursively calculate the polys and append them into filllist, but the array remians unalatered after running it. I know that as it stands there would be duplicates in the list, but I first want to get the function to actually do anything.%calculates polynomials of form Pk = ((2k-1)t/k)*Pk-1 – ((k-1)/k)*Pk-2
function [poly, filllist] = calc_poly (n, t, filllist)
if n == 0
filllist = [filllist; ones(size(t))];
poly = ones(size(t));
return
end
if n == 1
filllist = [filllist; t];
poly = t;
return
end
poly = ((2*n-1)/n)*t.*calc_poly(n-1, t, filllist) – ((n-1)/n)*calc_poly(n-2, t, filllist);
filllist = [filllist; poly];
end
This function is supposed to recursively calculate the polys and append them into filllist, but the array remians unalatered after running it. I know that as it stands there would be duplicates in the list, but I first want to get the function to actually do anything. %calculates polynomials of form Pk = ((2k-1)t/k)*Pk-1 – ((k-1)/k)*Pk-2
function [poly, filllist] = calc_poly (n, t, filllist)
if n == 0
filllist = [filllist; ones(size(t))];
poly = ones(size(t));
return
end
if n == 1
filllist = [filllist; t];
poly = t;
return
end
poly = ((2*n-1)/n)*t.*calc_poly(n-1, t, filllist) – ((n-1)/n)*calc_poly(n-2, t, filllist);
filllist = [filllist; poly];
end
This function is supposed to recursively calculate the polys and append them into filllist, but the array remians unalatered after running it. I know that as it stands there would be duplicates in the list, but I first want to get the function to actually do anything. matlab code, arrays, functions MATLAB Answers — New Questions
how to solve this problem?
When I run the code I get this error
clc;
% System parameters definition
m = 10;
A = [0 1; 0 0];
B = [0; 1/m];
C = [1 0; 0 1];
D = 0;
% State-space model creation
sys = ss(A, B, C, D);
% Number of experiments
N = 1000;
U = cell(N,1);
Y = cell(N,1);
rng(0);
%% Dataset generation for identification
for i = 1:N
% Generating random input sequence (force)
t = linspace(0, 1, 11)’;
u = 0.5 * randn(size(t));
% Random initial conditions for velocity and position
x0 = [0.5 * randn(1, 1); 0.5 * randn(1, 1)];
% System simulation
x = lsim(sys, u, t, x0);
% Saving input sequences and state measurements
U{i} = timetable(seconds(t), u);
Y{i} = timetable(seconds(t), x(:,1), x(:,2));
end
%% Generate Data Set for Validation
% Use random initial state and input sequence
t = linspace(0,10,101)’;
u = 0.5*randn(size(t));
x0 = [0.5*randn(1,1);0.5*randn(1,1)];
% Obtain state measurements over t
x = lsim(sys,u,t,x0);
% Append the validation experiment (also a timetable) as the last entry in the data set
U{end+1} = timetable(seconds(t), u);
Y{end+1} = timetable(seconds(t), x(:,1), x(:,2));
%% Creation and initialization of the state-space model
sys = idNeuralStateSpace(2, NumInputs=1); % Valid if nx=ny where nx is the number of states and ny is the number of outputs
sys.StateName = {‘Position’, ‘Velocity’}; % State variable names declaration
sys.InputName = ‘Force’; % Input name declaration (1 in this case)
sys.InputUnit = ‘N’;
sys.OutputName = {‘Position’, ‘Velocity’}; % Output names addition
sys.StateUnit = {‘m’, ‘m/s’};
sys.OutputUnit = sys.StateUnit;
sys.Notes = "Prediction Model using Neural Network";
%% Inner layers declaration for the state network
% State network
sys.StateNetwork = createMLPNetwork(sys, ‘state’, …
‘LayerSizes’, 128, …
‘Activations’, "tanh", …
‘WeightsInitializer’, "glorot", …
‘BiasInitializer’, "zeros");
%% Training options declaration for the state network
opt = nssTrainingOptions(‘adam’);
opt.MaxEpochs = 400;
opt.MiniBatchSize = N;
opt.LearnRate = 0.005;
%% Testing
resultTrain = nlssest(U, Y, sys, opt, ‘UseLastExperimentForValidation’, true);
where am I wrong?When I run the code I get this error
clc;
% System parameters definition
m = 10;
A = [0 1; 0 0];
B = [0; 1/m];
C = [1 0; 0 1];
D = 0;
% State-space model creation
sys = ss(A, B, C, D);
% Number of experiments
N = 1000;
U = cell(N,1);
Y = cell(N,1);
rng(0);
%% Dataset generation for identification
for i = 1:N
% Generating random input sequence (force)
t = linspace(0, 1, 11)’;
u = 0.5 * randn(size(t));
% Random initial conditions for velocity and position
x0 = [0.5 * randn(1, 1); 0.5 * randn(1, 1)];
% System simulation
x = lsim(sys, u, t, x0);
% Saving input sequences and state measurements
U{i} = timetable(seconds(t), u);
Y{i} = timetable(seconds(t), x(:,1), x(:,2));
end
%% Generate Data Set for Validation
% Use random initial state and input sequence
t = linspace(0,10,101)’;
u = 0.5*randn(size(t));
x0 = [0.5*randn(1,1);0.5*randn(1,1)];
% Obtain state measurements over t
x = lsim(sys,u,t,x0);
% Append the validation experiment (also a timetable) as the last entry in the data set
U{end+1} = timetable(seconds(t), u);
Y{end+1} = timetable(seconds(t), x(:,1), x(:,2));
%% Creation and initialization of the state-space model
sys = idNeuralStateSpace(2, NumInputs=1); % Valid if nx=ny where nx is the number of states and ny is the number of outputs
sys.StateName = {‘Position’, ‘Velocity’}; % State variable names declaration
sys.InputName = ‘Force’; % Input name declaration (1 in this case)
sys.InputUnit = ‘N’;
sys.OutputName = {‘Position’, ‘Velocity’}; % Output names addition
sys.StateUnit = {‘m’, ‘m/s’};
sys.OutputUnit = sys.StateUnit;
sys.Notes = "Prediction Model using Neural Network";
%% Inner layers declaration for the state network
% State network
sys.StateNetwork = createMLPNetwork(sys, ‘state’, …
‘LayerSizes’, 128, …
‘Activations’, "tanh", …
‘WeightsInitializer’, "glorot", …
‘BiasInitializer’, "zeros");
%% Training options declaration for the state network
opt = nssTrainingOptions(‘adam’);
opt.MaxEpochs = 400;
opt.MiniBatchSize = N;
opt.LearnRate = 0.005;
%% Testing
resultTrain = nlssest(U, Y, sys, opt, ‘UseLastExperimentForValidation’, true);
where am I wrong? When I run the code I get this error
clc;
% System parameters definition
m = 10;
A = [0 1; 0 0];
B = [0; 1/m];
C = [1 0; 0 1];
D = 0;
% State-space model creation
sys = ss(A, B, C, D);
% Number of experiments
N = 1000;
U = cell(N,1);
Y = cell(N,1);
rng(0);
%% Dataset generation for identification
for i = 1:N
% Generating random input sequence (force)
t = linspace(0, 1, 11)’;
u = 0.5 * randn(size(t));
% Random initial conditions for velocity and position
x0 = [0.5 * randn(1, 1); 0.5 * randn(1, 1)];
% System simulation
x = lsim(sys, u, t, x0);
% Saving input sequences and state measurements
U{i} = timetable(seconds(t), u);
Y{i} = timetable(seconds(t), x(:,1), x(:,2));
end
%% Generate Data Set for Validation
% Use random initial state and input sequence
t = linspace(0,10,101)’;
u = 0.5*randn(size(t));
x0 = [0.5*randn(1,1);0.5*randn(1,1)];
% Obtain state measurements over t
x = lsim(sys,u,t,x0);
% Append the validation experiment (also a timetable) as the last entry in the data set
U{end+1} = timetable(seconds(t), u);
Y{end+1} = timetable(seconds(t), x(:,1), x(:,2));
%% Creation and initialization of the state-space model
sys = idNeuralStateSpace(2, NumInputs=1); % Valid if nx=ny where nx is the number of states and ny is the number of outputs
sys.StateName = {‘Position’, ‘Velocity’}; % State variable names declaration
sys.InputName = ‘Force’; % Input name declaration (1 in this case)
sys.InputUnit = ‘N’;
sys.OutputName = {‘Position’, ‘Velocity’}; % Output names addition
sys.StateUnit = {‘m’, ‘m/s’};
sys.OutputUnit = sys.StateUnit;
sys.Notes = "Prediction Model using Neural Network";
%% Inner layers declaration for the state network
% State network
sys.StateNetwork = createMLPNetwork(sys, ‘state’, …
‘LayerSizes’, 128, …
‘Activations’, "tanh", …
‘WeightsInitializer’, "glorot", …
‘BiasInitializer’, "zeros");
%% Training options declaration for the state network
opt = nssTrainingOptions(‘adam’);
opt.MaxEpochs = 400;
opt.MiniBatchSize = N;
opt.LearnRate = 0.005;
%% Testing
resultTrain = nlssest(U, Y, sys, opt, ‘UseLastExperimentForValidation’, true);
where am I wrong? nlssest, matlab code MATLAB Answers — New Questions
How can I display a line in 3D with a colour gradient?
Let’s say I have a set of 10 tridimensional points, represented as a 3 by 10 matrix, such as these points generated just for the sake of illustration:
n = 10;
x = linspace(1, 2, n);
y = cos(x);
z = y.^2;
points = [x’ y’ z’]
I can display them as a line in 3D:
plot3(points(:,1,:), points(:,2,:), points(:,3,:));
My question is: how can I apply a color gradient to this line, so we can see in what direction does the line evolve (relative to the order of the point in the points matrix)?
I tried several methods, without success so far:
Calling plot3 with the c parameter (as suggested by an answer on the Internet): the c keyword is not recognised.
Calling colormap with a custom made map: no graph is displayed at all, even though no error is thrown.
cmap = [linspace(0, 1, n)’ zeros(n, 1) zeros(n, 1)];
colormap(cmap);Let’s say I have a set of 10 tridimensional points, represented as a 3 by 10 matrix, such as these points generated just for the sake of illustration:
n = 10;
x = linspace(1, 2, n);
y = cos(x);
z = y.^2;
points = [x’ y’ z’]
I can display them as a line in 3D:
plot3(points(:,1,:), points(:,2,:), points(:,3,:));
My question is: how can I apply a color gradient to this line, so we can see in what direction does the line evolve (relative to the order of the point in the points matrix)?
I tried several methods, without success so far:
Calling plot3 with the c parameter (as suggested by an answer on the Internet): the c keyword is not recognised.
Calling colormap with a custom made map: no graph is displayed at all, even though no error is thrown.
cmap = [linspace(0, 1, n)’ zeros(n, 1) zeros(n, 1)];
colormap(cmap); Let’s say I have a set of 10 tridimensional points, represented as a 3 by 10 matrix, such as these points generated just for the sake of illustration:
n = 10;
x = linspace(1, 2, n);
y = cos(x);
z = y.^2;
points = [x’ y’ z’]
I can display them as a line in 3D:
plot3(points(:,1,:), points(:,2,:), points(:,3,:));
My question is: how can I apply a color gradient to this line, so we can see in what direction does the line evolve (relative to the order of the point in the points matrix)?
I tried several methods, without success so far:
Calling plot3 with the c parameter (as suggested by an answer on the Internet): the c keyword is not recognised.
Calling colormap with a custom made map: no graph is displayed at all, even though no error is thrown.
cmap = [linspace(0, 1, n)’ zeros(n, 1) zeros(n, 1)];
colormap(cmap); plot3, colormap MATLAB Answers — New Questions
Additional CSP partner Benefits for lighting up Azure Services
Folks – Curious as a MSFT CSP, were lighting up more and more Azure internal services on our tenant, such as Lighthouse and will seek to turn around and repackage/resell to customers. Anyone know(besides the specializations) if there are other MSFT benefits/programs/credits/incentives to lighting up services(Arc, Purview, Monitor etc…) in Azure? TIA
Folks – Curious as a MSFT CSP, were lighting up more and more Azure internal services on our tenant, such as Lighthouse and will seek to turn around and repackage/resell to customers. Anyone know(besides the specializations) if there are other MSFT benefits/programs/credits/incentives to lighting up services(Arc, Purview, Monitor etc…) in Azure? TIA Read More