Category: Matlab
Category Archives: Matlab
How can I control the output data type of the “Signal Editor” block?
How can I control the output data type of the "Signal Editor" block?How can I control the output data type of the "Signal Editor" block? How can I control the output data type of the "Signal Editor" block? signal, editor, simulink, data, types, mat, file, output MATLAB Answers — New Questions
How i get a graph that i attached here with this matlab code?
function HTP()
clc
clear all format long % hybrid Carreau
% Define constants
J1 = 0.1;
J2 = 0.1;
J3 = 0.1;
J4 = 0.1;
JS = 0.1;
z = 0.1;
S = 0.1;
GC = 0.1;
Gr = 0.1;
H = 0.1;
a = 0.1;
m = 1;
G = 0.5;
phi = 0.1;
% Define time vector
t = linspace(0, 5, 100); % 100 points between 0 and 5
%t= 1;
% Calculate u1 and u2
u1 = exp(-t) – 1;
% Compute u2 with corrected parentheses and mathematical operations
exp_t = exp(t); % Compute exp(t) once for efficiency
term1 = -33 / J1 * (1 – exp_t – z / 3 * S);
term2 = 2 * GC * J3 + 2 * Gr * J2;
term3 = (2 * J4 * H * a^2) / (1 + m^2);
term4 = 3 * G * exp_t + 6 * exp_t / ((1 – phi)^2.5);
term5 = 2 * GC * JS * exp_t + 2 * Gr * J2 * exp_t;
u2 = (term1 + term2 – term3 – term4 – term5 + term3 * (exp_t – m + m * exp_t)) / (6 * a);
% Compute u
y = 1; % Define y as 1 or another constant value; adjust as needed
u = u1 * y + u2 * y.^2;
% Plot the result
phi = 0.1
figure ;
plot(t, u);
phi= 0.2
figure ;
plot(t, u);
phi = 0.3
figure ;
plot(t, u);
phi = 0.4
figure ;
plot(t, u);
xlabel(‘Time (t)’);
ylabel(‘u(t)’);
title(‘Plot of u(t)’);
axis([0 5 min(u) max(u)]);
grid on;
endfunction HTP()
clc
clear all format long % hybrid Carreau
% Define constants
J1 = 0.1;
J2 = 0.1;
J3 = 0.1;
J4 = 0.1;
JS = 0.1;
z = 0.1;
S = 0.1;
GC = 0.1;
Gr = 0.1;
H = 0.1;
a = 0.1;
m = 1;
G = 0.5;
phi = 0.1;
% Define time vector
t = linspace(0, 5, 100); % 100 points between 0 and 5
%t= 1;
% Calculate u1 and u2
u1 = exp(-t) – 1;
% Compute u2 with corrected parentheses and mathematical operations
exp_t = exp(t); % Compute exp(t) once for efficiency
term1 = -33 / J1 * (1 – exp_t – z / 3 * S);
term2 = 2 * GC * J3 + 2 * Gr * J2;
term3 = (2 * J4 * H * a^2) / (1 + m^2);
term4 = 3 * G * exp_t + 6 * exp_t / ((1 – phi)^2.5);
term5 = 2 * GC * JS * exp_t + 2 * Gr * J2 * exp_t;
u2 = (term1 + term2 – term3 – term4 – term5 + term3 * (exp_t – m + m * exp_t)) / (6 * a);
% Compute u
y = 1; % Define y as 1 or another constant value; adjust as needed
u = u1 * y + u2 * y.^2;
% Plot the result
phi = 0.1
figure ;
plot(t, u);
phi= 0.2
figure ;
plot(t, u);
phi = 0.3
figure ;
plot(t, u);
phi = 0.4
figure ;
plot(t, u);
xlabel(‘Time (t)’);
ylabel(‘u(t)’);
title(‘Plot of u(t)’);
axis([0 5 min(u) max(u)]);
grid on;
end function HTP()
clc
clear all format long % hybrid Carreau
% Define constants
J1 = 0.1;
J2 = 0.1;
J3 = 0.1;
J4 = 0.1;
JS = 0.1;
z = 0.1;
S = 0.1;
GC = 0.1;
Gr = 0.1;
H = 0.1;
a = 0.1;
m = 1;
G = 0.5;
phi = 0.1;
% Define time vector
t = linspace(0, 5, 100); % 100 points between 0 and 5
%t= 1;
% Calculate u1 and u2
u1 = exp(-t) – 1;
% Compute u2 with corrected parentheses and mathematical operations
exp_t = exp(t); % Compute exp(t) once for efficiency
term1 = -33 / J1 * (1 – exp_t – z / 3 * S);
term2 = 2 * GC * J3 + 2 * Gr * J2;
term3 = (2 * J4 * H * a^2) / (1 + m^2);
term4 = 3 * G * exp_t + 6 * exp_t / ((1 – phi)^2.5);
term5 = 2 * GC * JS * exp_t + 2 * Gr * J2 * exp_t;
u2 = (term1 + term2 – term3 – term4 – term5 + term3 * (exp_t – m + m * exp_t)) / (6 * a);
% Compute u
y = 1; % Define y as 1 or another constant value; adjust as needed
u = u1 * y + u2 * y.^2;
% Plot the result
phi = 0.1
figure ;
plot(t, u);
phi= 0.2
figure ;
plot(t, u);
phi = 0.3
figure ;
plot(t, u);
phi = 0.4
figure ;
plot(t, u);
xlabel(‘Time (t)’);
ylabel(‘u(t)’);
title(‘Plot of u(t)’);
axis([0 5 min(u) max(u)]);
grid on;
end multiple lines in one graph MATLAB Answers — New Questions
write a function called tri_area returns the area of a triangle with base b and height h
hello this is my function code and command window code and there is a message of invalid expression at line 2 and i dont know what is the wrong can anyone help me
function [area] = tri_area([b,h]);
tri_area([b,h])=(0.5)*(b)*(h)
area=tri_area([b,h])
end
%command window
area = tri_area[3,2])hello this is my function code and command window code and there is a message of invalid expression at line 2 and i dont know what is the wrong can anyone help me
function [area] = tri_area([b,h]);
tri_area([b,h])=(0.5)*(b)*(h)
area=tri_area([b,h])
end
%command window
area = tri_area[3,2]) hello this is my function code and command window code and there is a message of invalid expression at line 2 and i dont know what is the wrong can anyone help me
function [area] = tri_area([b,h]);
tri_area([b,h])=(0.5)*(b)*(h)
area=tri_area([b,h])
end
%command window
area = tri_area[3,2]) matlab function, homework MATLAB Answers — New Questions
Copy-pasting variables (values) to edior in 2021b
Copy-pasting column vector values from workspace to editor used to automatically include ; and give me everything in a nicely formated single row. After updating to 2021b it results in a long list of values (each one in a separate row).
For example:
Create a column vector:
> A = [1; 2; 3; 4; 5];
Open it in the workspace, select entire column and copy (ctrl-c)
Paste in the editor results with:
1
2
3
4
5
while it used to result with:
1;2;3;4;5
Is there a way to switch back to the old behavior of copy-pasting variables?
I use it a lot, for example when saving the results in my scripts as starting values for the future and the new format makes the scripts much longer and messier.
Thank you very much in advance for any suggestions.Copy-pasting column vector values from workspace to editor used to automatically include ; and give me everything in a nicely formated single row. After updating to 2021b it results in a long list of values (each one in a separate row).
For example:
Create a column vector:
> A = [1; 2; 3; 4; 5];
Open it in the workspace, select entire column and copy (ctrl-c)
Paste in the editor results with:
1
2
3
4
5
while it used to result with:
1;2;3;4;5
Is there a way to switch back to the old behavior of copy-pasting variables?
I use it a lot, for example when saving the results in my scripts as starting values for the future and the new format makes the scripts much longer and messier.
Thank you very much in advance for any suggestions. Copy-pasting column vector values from workspace to editor used to automatically include ; and give me everything in a nicely formated single row. After updating to 2021b it results in a long list of values (each one in a separate row).
For example:
Create a column vector:
> A = [1; 2; 3; 4; 5];
Open it in the workspace, select entire column and copy (ctrl-c)
Paste in the editor results with:
1
2
3
4
5
while it used to result with:
1;2;3;4;5
Is there a way to switch back to the old behavior of copy-pasting variables?
I use it a lot, for example when saving the results in my scripts as starting values for the future and the new format makes the scripts much longer and messier.
Thank you very much in advance for any suggestions. copy-paste, editor, variables, 2021b update MATLAB Answers — New Questions
appdesigner tab view issue
Hi:
I have an app that showing the tab group at left, I noticed that when the tab name is too long, it will not be fully displayed. I tried to drag the corners of the tab but still not work, as shown in screen shot.
is there anyway to address this issue? i.e. to let the tab names fully shown.
Thanks!
YuHi:
I have an app that showing the tab group at left, I noticed that when the tab name is too long, it will not be fully displayed. I tried to drag the corners of the tab but still not work, as shown in screen shot.
is there anyway to address this issue? i.e. to let the tab names fully shown.
Thanks!
Yu Hi:
I have an app that showing the tab group at left, I noticed that when the tab name is too long, it will not be fully displayed. I tried to drag the corners of the tab but still not work, as shown in screen shot.
is there anyway to address this issue? i.e. to let the tab names fully shown.
Thanks!
Yu appdesigner tab view issue MATLAB Answers — New Questions
PNG Library Filed: Not a PNG File
Image Processing ToolBox, The function "imread" can not identify .png file. Why is this???Image Processing ToolBox, The function "imread" can not identify .png file. Why is this??? Image Processing ToolBox, The function "imread" can not identify .png file. Why is this??? image processing toolbox, imread MATLAB Answers — New Questions
How to solve diffusion equation by the crank – Nicolson method?
I have a diffusion equation 1D:
dC/dt =D*d2C/dx2
with D is changed with time.
Hepl me……
Thank you so much!I have a diffusion equation 1D:
dC/dt =D*d2C/dx2
with D is changed with time.
Hepl me……
Thank you so much! I have a diffusion equation 1D:
dC/dt =D*d2C/dx2
with D is changed with time.
Hepl me……
Thank you so much! MATLAB Answers — New Questions
Why is my model not converging with ode45 solver ?
I am trying to simulate an electronical device that can be modeled by a mass-spring-damper system with an additional non-linear force. The equation at the equilibrium for the system is the following :
The goal of my MATLAB code is to solve this equation for $x$ and find the equilibrium. For this purpose, I use the `ode45` function like this (all coefficient are defined in my code but not shown here) :
x0 = 0;
[t, x] = ode45(@(t, x) odefun(t, x, eps0, a, V0, B, d0, K), tspan, x0);
function dxdt = odefun(t, x, eps, a, V, B, d0, K)
dxdt = ((eps * a * V^2) ./ (2 * B * (d0 – x).^2)) + ((K / B) .* x);
end
The equation is good according to my teachers and several papers but the solver never converges and I can’t see why. All coefficient are defined according to the dimensions of a capacitive micromachined ultrasound transducer. The solution of ode45 is the following :
This is obviously wrong because the dimensions of a cmut are bellow millimeter.
Can you see any mistakes in the way I use the ode45 solver ?
Full code :
% DIMENSIONS DE LA MEMBRANE
e = 500e-9; % epaisseur [m]
r = 20e-6; % rayon [m]
d0 = 550e-9; % epaisseur de cavite [m]
a = pi * r^2; % surface de la membrane [m^2]
% PARAMETRES MECANIQUES
E = 200e9; % module d’Young du SiN [Pa]
nu = 0.25; % coefficient de poisson du SiN
eta = 18.5e-6; % viscosité dynamique de l’air [Pa.s]
p0 = 1e5; % pression exterieure [Pa]
rhoSiN = 3170; % densite du SiN [Kg/m^3]
m = rhoSiN * a * e; % masse membrane [Kg]
K = (16 * E * e^3) / (3 * (1 – nu^2) * r^2); % raideur [N/m]
B = (eta * pi * r^2) / e; % amortissement [N.s/m]
% PARAMETRES ELECTRIQUES
eps0 = 8.85e-12; % permittivité diélectrique du vide [F/m]
V0 = 10; % tension de polarisation [V]
% Conditions initiales et plage de temps
x0 = 0;
ti = 0; tf = 1e-3;
dt = 1e-6;
tspan = linspace(ti, tf, 1/dt);
% Résolution par RK4
[t, x] = ode45(@(t, x) odefun(t, x, eps0, a, V0, B, d0, K), tspan, x0);
plot(t,x,’-‘)
function dxdt = odefun(t, x, eps, a, V, B, d0, K)
dxdt = ((eps * a * V^2) ./ (2 * B * (d0 – x).^2)) + ((K / B) .* x);
end
References :
– Y. Wang, L. -M. He, Z. Li, W. Xu and J. Ren, "A computationally efficient nonlinear dynamic model for cMUT based on COMSOL and MATLAB/Simulink"
– T. Merrien, A. Boulmé and D. Certon, "Lumped-Parameter Equivalent Circuit Modeling of CMUT Array Elements"
I tried several solver from MATLAB and implemented my own Runge-Kutta algorithm based on the Wikipedia example. I also verified the coefficients according to my references.I am trying to simulate an electronical device that can be modeled by a mass-spring-damper system with an additional non-linear force. The equation at the equilibrium for the system is the following :
The goal of my MATLAB code is to solve this equation for $x$ and find the equilibrium. For this purpose, I use the `ode45` function like this (all coefficient are defined in my code but not shown here) :
x0 = 0;
[t, x] = ode45(@(t, x) odefun(t, x, eps0, a, V0, B, d0, K), tspan, x0);
function dxdt = odefun(t, x, eps, a, V, B, d0, K)
dxdt = ((eps * a * V^2) ./ (2 * B * (d0 – x).^2)) + ((K / B) .* x);
end
The equation is good according to my teachers and several papers but the solver never converges and I can’t see why. All coefficient are defined according to the dimensions of a capacitive micromachined ultrasound transducer. The solution of ode45 is the following :
This is obviously wrong because the dimensions of a cmut are bellow millimeter.
Can you see any mistakes in the way I use the ode45 solver ?
Full code :
% DIMENSIONS DE LA MEMBRANE
e = 500e-9; % epaisseur [m]
r = 20e-6; % rayon [m]
d0 = 550e-9; % epaisseur de cavite [m]
a = pi * r^2; % surface de la membrane [m^2]
% PARAMETRES MECANIQUES
E = 200e9; % module d’Young du SiN [Pa]
nu = 0.25; % coefficient de poisson du SiN
eta = 18.5e-6; % viscosité dynamique de l’air [Pa.s]
p0 = 1e5; % pression exterieure [Pa]
rhoSiN = 3170; % densite du SiN [Kg/m^3]
m = rhoSiN * a * e; % masse membrane [Kg]
K = (16 * E * e^3) / (3 * (1 – nu^2) * r^2); % raideur [N/m]
B = (eta * pi * r^2) / e; % amortissement [N.s/m]
% PARAMETRES ELECTRIQUES
eps0 = 8.85e-12; % permittivité diélectrique du vide [F/m]
V0 = 10; % tension de polarisation [V]
% Conditions initiales et plage de temps
x0 = 0;
ti = 0; tf = 1e-3;
dt = 1e-6;
tspan = linspace(ti, tf, 1/dt);
% Résolution par RK4
[t, x] = ode45(@(t, x) odefun(t, x, eps0, a, V0, B, d0, K), tspan, x0);
plot(t,x,’-‘)
function dxdt = odefun(t, x, eps, a, V, B, d0, K)
dxdt = ((eps * a * V^2) ./ (2 * B * (d0 – x).^2)) + ((K / B) .* x);
end
References :
– Y. Wang, L. -M. He, Z. Li, W. Xu and J. Ren, "A computationally efficient nonlinear dynamic model for cMUT based on COMSOL and MATLAB/Simulink"
– T. Merrien, A. Boulmé and D. Certon, "Lumped-Parameter Equivalent Circuit Modeling of CMUT Array Elements"
I tried several solver from MATLAB and implemented my own Runge-Kutta algorithm based on the Wikipedia example. I also verified the coefficients according to my references. I am trying to simulate an electronical device that can be modeled by a mass-spring-damper system with an additional non-linear force. The equation at the equilibrium for the system is the following :
The goal of my MATLAB code is to solve this equation for $x$ and find the equilibrium. For this purpose, I use the `ode45` function like this (all coefficient are defined in my code but not shown here) :
x0 = 0;
[t, x] = ode45(@(t, x) odefun(t, x, eps0, a, V0, B, d0, K), tspan, x0);
function dxdt = odefun(t, x, eps, a, V, B, d0, K)
dxdt = ((eps * a * V^2) ./ (2 * B * (d0 – x).^2)) + ((K / B) .* x);
end
The equation is good according to my teachers and several papers but the solver never converges and I can’t see why. All coefficient are defined according to the dimensions of a capacitive micromachined ultrasound transducer. The solution of ode45 is the following :
This is obviously wrong because the dimensions of a cmut are bellow millimeter.
Can you see any mistakes in the way I use the ode45 solver ?
Full code :
% DIMENSIONS DE LA MEMBRANE
e = 500e-9; % epaisseur [m]
r = 20e-6; % rayon [m]
d0 = 550e-9; % epaisseur de cavite [m]
a = pi * r^2; % surface de la membrane [m^2]
% PARAMETRES MECANIQUES
E = 200e9; % module d’Young du SiN [Pa]
nu = 0.25; % coefficient de poisson du SiN
eta = 18.5e-6; % viscosité dynamique de l’air [Pa.s]
p0 = 1e5; % pression exterieure [Pa]
rhoSiN = 3170; % densite du SiN [Kg/m^3]
m = rhoSiN * a * e; % masse membrane [Kg]
K = (16 * E * e^3) / (3 * (1 – nu^2) * r^2); % raideur [N/m]
B = (eta * pi * r^2) / e; % amortissement [N.s/m]
% PARAMETRES ELECTRIQUES
eps0 = 8.85e-12; % permittivité diélectrique du vide [F/m]
V0 = 10; % tension de polarisation [V]
% Conditions initiales et plage de temps
x0 = 0;
ti = 0; tf = 1e-3;
dt = 1e-6;
tspan = linspace(ti, tf, 1/dt);
% Résolution par RK4
[t, x] = ode45(@(t, x) odefun(t, x, eps0, a, V0, B, d0, K), tspan, x0);
plot(t,x,’-‘)
function dxdt = odefun(t, x, eps, a, V, B, d0, K)
dxdt = ((eps * a * V^2) ./ (2 * B * (d0 – x).^2)) + ((K / B) .* x);
end
References :
– Y. Wang, L. -M. He, Z. Li, W. Xu and J. Ren, "A computationally efficient nonlinear dynamic model for cMUT based on COMSOL and MATLAB/Simulink"
– T. Merrien, A. Boulmé and D. Certon, "Lumped-Parameter Equivalent Circuit Modeling of CMUT Array Elements"
I tried several solver from MATLAB and implemented my own Runge-Kutta algorithm based on the Wikipedia example. I also verified the coefficients according to my references. differential equations, physics, matlab, model, ode45, ode MATLAB Answers — New Questions
How to correctly abort a running Matlab function/thread in a .NET Assembly in .NET8?
Dear MathWorks team
In our .NET Framework 4.7.2 application we instanciate a class from a Matlab .NET assembly and call one function to calculate.
The call is done in a own background thread of the application.
If the calculation takes too long or the calculation request has been canceled, we just aborted the .NET thread with thread.Abort().
.NET core (at least v8) does not support the Abort() function anymore. The only general alternative suggestion I could find is to outsource the call into an own process and then kill the process if required. This seems to be quite complicated and Matlab takes a few seconds to initialize on the first call, which is too slow for us.
Is there any best practice / example how to achieve this?
Thanks in advance
Public Sub New(ByVal theTimeout As Integer, theData As Object, theWorkerMethod As TheWorkerDelegate, theCompleteCallback As CompleteCallbackDelegate, theSynchObj As ISynchronizeInvoke)
_theData = theData
_theCompleteCallback = theCompleteCallback
_theWorkerMethod = theWorkerMethod
_theSyncObject = theSynchObj
If theTimeout > 0 Then
_timeoutTimer = New WcsTimer(theTimeout * 1000, WcsTimer.TimerMode.SingleShot)
AddHandler _timeoutTimer.TimeElapsed, AddressOf _timeoutTimerElapsed
End If
_theThread = New Threading.Thread(AddressOf _startWorkerThread)
_theThread.Name = "Matlab Supervision Thread"
_theThread.Start()
End Sub
Public Sub Abort()
_stopTimeoutTimer()
If _theThread IsNot Nothing AndAlso _theThread.IsAlive Then
_theThread.Abort()
End If
_theThread = Nothing
End Sub
Private Sub _startWorkerThread()
Dim theEx As Exception = Nothing
Try
_theWorkerMethod(_theData) -> Matlab call
Catch ex As Exception
theEx = ex
End Try
_stopTimeoutTimer()
Dim p As Object() = {_theData, False, theEx}
_theSyncObject.Invoke(_theCompleteCallback, p)
End Sub
Private Sub _timeoutTimerElapsed(sender As Object, e As EventArgs)
WcsTrace.Log(WcsTrace.Category.Detailed, $"********* BackgroupWorker Timeoute -> Abort **************")
Abort()
_theCompleteCallback(_theData, True, Nothing)
End SubDear MathWorks team
In our .NET Framework 4.7.2 application we instanciate a class from a Matlab .NET assembly and call one function to calculate.
The call is done in a own background thread of the application.
If the calculation takes too long or the calculation request has been canceled, we just aborted the .NET thread with thread.Abort().
.NET core (at least v8) does not support the Abort() function anymore. The only general alternative suggestion I could find is to outsource the call into an own process and then kill the process if required. This seems to be quite complicated and Matlab takes a few seconds to initialize on the first call, which is too slow for us.
Is there any best practice / example how to achieve this?
Thanks in advance
Public Sub New(ByVal theTimeout As Integer, theData As Object, theWorkerMethod As TheWorkerDelegate, theCompleteCallback As CompleteCallbackDelegate, theSynchObj As ISynchronizeInvoke)
_theData = theData
_theCompleteCallback = theCompleteCallback
_theWorkerMethod = theWorkerMethod
_theSyncObject = theSynchObj
If theTimeout > 0 Then
_timeoutTimer = New WcsTimer(theTimeout * 1000, WcsTimer.TimerMode.SingleShot)
AddHandler _timeoutTimer.TimeElapsed, AddressOf _timeoutTimerElapsed
End If
_theThread = New Threading.Thread(AddressOf _startWorkerThread)
_theThread.Name = "Matlab Supervision Thread"
_theThread.Start()
End Sub
Public Sub Abort()
_stopTimeoutTimer()
If _theThread IsNot Nothing AndAlso _theThread.IsAlive Then
_theThread.Abort()
End If
_theThread = Nothing
End Sub
Private Sub _startWorkerThread()
Dim theEx As Exception = Nothing
Try
_theWorkerMethod(_theData) -> Matlab call
Catch ex As Exception
theEx = ex
End Try
_stopTimeoutTimer()
Dim p As Object() = {_theData, False, theEx}
_theSyncObject.Invoke(_theCompleteCallback, p)
End Sub
Private Sub _timeoutTimerElapsed(sender As Object, e As EventArgs)
WcsTrace.Log(WcsTrace.Category.Detailed, $"********* BackgroupWorker Timeoute -> Abort **************")
Abort()
_theCompleteCallback(_theData, True, Nothing)
End Sub Dear MathWorks team
In our .NET Framework 4.7.2 application we instanciate a class from a Matlab .NET assembly and call one function to calculate.
The call is done in a own background thread of the application.
If the calculation takes too long or the calculation request has been canceled, we just aborted the .NET thread with thread.Abort().
.NET core (at least v8) does not support the Abort() function anymore. The only general alternative suggestion I could find is to outsource the call into an own process and then kill the process if required. This seems to be quite complicated and Matlab takes a few seconds to initialize on the first call, which is too slow for us.
Is there any best practice / example how to achieve this?
Thanks in advance
Public Sub New(ByVal theTimeout As Integer, theData As Object, theWorkerMethod As TheWorkerDelegate, theCompleteCallback As CompleteCallbackDelegate, theSynchObj As ISynchronizeInvoke)
_theData = theData
_theCompleteCallback = theCompleteCallback
_theWorkerMethod = theWorkerMethod
_theSyncObject = theSynchObj
If theTimeout > 0 Then
_timeoutTimer = New WcsTimer(theTimeout * 1000, WcsTimer.TimerMode.SingleShot)
AddHandler _timeoutTimer.TimeElapsed, AddressOf _timeoutTimerElapsed
End If
_theThread = New Threading.Thread(AddressOf _startWorkerThread)
_theThread.Name = "Matlab Supervision Thread"
_theThread.Start()
End Sub
Public Sub Abort()
_stopTimeoutTimer()
If _theThread IsNot Nothing AndAlso _theThread.IsAlive Then
_theThread.Abort()
End If
_theThread = Nothing
End Sub
Private Sub _startWorkerThread()
Dim theEx As Exception = Nothing
Try
_theWorkerMethod(_theData) -> Matlab call
Catch ex As Exception
theEx = ex
End Try
_stopTimeoutTimer()
Dim p As Object() = {_theData, False, theEx}
_theSyncObject.Invoke(_theCompleteCallback, p)
End Sub
Private Sub _timeoutTimerElapsed(sender As Object, e As EventArgs)
WcsTrace.Log(WcsTrace.Category.Detailed, $"********* BackgroupWorker Timeoute -> Abort **************")
Abort()
_theCompleteCallback(_theData, True, Nothing)
End Sub .net8, thread, abort MATLAB Answers — New Questions
HDL Coder; Matlab Function Blocks and Clocked Processes
I belive my request is quite straigth forward.
I want the logic of my Matlab Funciton Block to be generated as clocked logic and not combinatorial logic.
Lets use the eml_hdl_incrementer example.
It generates
eml_inc_blk_1_output : PROCESS (ctr_preset, ctr_preset_val_unsigned, current_count)
But I would want it to generate
eml_inc_blk_1_output : PROCESS (clk)
I mean it should not be a miracle to achieve, but I could not find an option, that allows me to enforce this behaviour.
Is there an option to make matlab generate a clocked process or do I have to use specific patterns in my funciton?I belive my request is quite straigth forward.
I want the logic of my Matlab Funciton Block to be generated as clocked logic and not combinatorial logic.
Lets use the eml_hdl_incrementer example.
It generates
eml_inc_blk_1_output : PROCESS (ctr_preset, ctr_preset_val_unsigned, current_count)
But I would want it to generate
eml_inc_blk_1_output : PROCESS (clk)
I mean it should not be a miracle to achieve, but I could not find an option, that allows me to enforce this behaviour.
Is there an option to make matlab generate a clocked process or do I have to use specific patterns in my funciton? I belive my request is quite straigth forward.
I want the logic of my Matlab Funciton Block to be generated as clocked logic and not combinatorial logic.
Lets use the eml_hdl_incrementer example.
It generates
eml_inc_blk_1_output : PROCESS (ctr_preset, ctr_preset_val_unsigned, current_count)
But I would want it to generate
eml_inc_blk_1_output : PROCESS (clk)
I mean it should not be a miracle to achieve, but I could not find an option, that allows me to enforce this behaviour.
Is there an option to make matlab generate a clocked process or do I have to use specific patterns in my funciton? hdl coder, clocked process MATLAB Answers — New Questions
how to plot from .csv file?
i hv to find percentage difference values for columns 3,6,9,12 for 2 pol HH and VV separatelyand find out difference at each frequency
later at x axis frequency and y axis these indivdual percentage values has to be plotted in bar chart
A=csvread(‘baseline.csv’,1,0)
freq=A(1:6,2);
A_1_PE_HH=A(1:6,3);
B_2_PE_HH=A(1:6,9);
A_1_fre_HH=A(1:6,6);
B_2_fre_HH=A(1:6,12);
HH_1st_example=((A_1_PE_HH(2,1)-B_2_PE_HH(2,1))/A_1_PE_HH(2,1))*100 %finding percentage differnce between 3 and 6 columns
HH_2nd_example=((A_1_PE_HH(2,1)-B_2_fre_HH(2,1))A_1_PE_HH(2,1))*100 %finding percentage differnce between 3 and 12 columns
HH_3rd_example=((A_1_fre_HH(2,1)-B_2_PE_HH(2,1))/A_1_fre_HH(2,1))*100 %finding percentage differnce between 6 and 9 columns
HH_4th_example=((A_1_fre_HH(2,1)-B_2_fre_HH(2,1))/A_1_PE_HH(2,1))*100 %finding percentage differnce between 6 and 12 columns
same i have to find for VV also i m getting stuck at this placei hv to find percentage difference values for columns 3,6,9,12 for 2 pol HH and VV separatelyand find out difference at each frequency
later at x axis frequency and y axis these indivdual percentage values has to be plotted in bar chart
A=csvread(‘baseline.csv’,1,0)
freq=A(1:6,2);
A_1_PE_HH=A(1:6,3);
B_2_PE_HH=A(1:6,9);
A_1_fre_HH=A(1:6,6);
B_2_fre_HH=A(1:6,12);
HH_1st_example=((A_1_PE_HH(2,1)-B_2_PE_HH(2,1))/A_1_PE_HH(2,1))*100 %finding percentage differnce between 3 and 6 columns
HH_2nd_example=((A_1_PE_HH(2,1)-B_2_fre_HH(2,1))A_1_PE_HH(2,1))*100 %finding percentage differnce between 3 and 12 columns
HH_3rd_example=((A_1_fre_HH(2,1)-B_2_PE_HH(2,1))/A_1_fre_HH(2,1))*100 %finding percentage differnce between 6 and 9 columns
HH_4th_example=((A_1_fre_HH(2,1)-B_2_fre_HH(2,1))/A_1_PE_HH(2,1))*100 %finding percentage differnce between 6 and 12 columns
same i have to find for VV also i m getting stuck at this place i hv to find percentage difference values for columns 3,6,9,12 for 2 pol HH and VV separatelyand find out difference at each frequency
later at x axis frequency and y axis these indivdual percentage values has to be plotted in bar chart
A=csvread(‘baseline.csv’,1,0)
freq=A(1:6,2);
A_1_PE_HH=A(1:6,3);
B_2_PE_HH=A(1:6,9);
A_1_fre_HH=A(1:6,6);
B_2_fre_HH=A(1:6,12);
HH_1st_example=((A_1_PE_HH(2,1)-B_2_PE_HH(2,1))/A_1_PE_HH(2,1))*100 %finding percentage differnce between 3 and 6 columns
HH_2nd_example=((A_1_PE_HH(2,1)-B_2_fre_HH(2,1))A_1_PE_HH(2,1))*100 %finding percentage differnce between 3 and 12 columns
HH_3rd_example=((A_1_fre_HH(2,1)-B_2_PE_HH(2,1))/A_1_fre_HH(2,1))*100 %finding percentage differnce between 6 and 9 columns
HH_4th_example=((A_1_fre_HH(2,1)-B_2_fre_HH(2,1))/A_1_PE_HH(2,1))*100 %finding percentage differnce between 6 and 12 columns
same i have to find for VV also i m getting stuck at this place plot MATLAB Answers — New Questions
Transforming Optimization Code from Problem-Based to Solver-Based Approach in MATLAB
Hello,
I have successfully implemented an ILP problem using MATLAB’s problem-based optimization approach. However, I am now looking to switch to the solver-based approach to take advantage of its flexibility and efficiency.
In the problem-based approach, I defined binary decision variables, constraints, and an objective function using optimvar, optimconstr, and optimexpr. The code works well, but I need guidance on how to transform this code into a solver-based format using intlinprog.
Here’s a summary of what I have:
Decision Variables:
A 3D binary matrix A(N, numNodes, num_vehicles) for task assignment.
A binary vector chi(num_vehicles) for satisfaction.
Other binary variables like z, t_wait_aux, etc.
Constraints:
Assignment constraints, dependency constraints, and time-based constraints.
I linearized expressions using auxiliary variables and max constraints.
Objective Function:
The objective is to maximize the satisfaction rate, expressed as a linear function of chi.
Could you provide guidance or directions how to systematically convert my existing problem-based variables and constraints into the matrix form required by intlinprog
Here is the code
the problem is attached.
Thank you for your continued help!Hello,
I have successfully implemented an ILP problem using MATLAB’s problem-based optimization approach. However, I am now looking to switch to the solver-based approach to take advantage of its flexibility and efficiency.
In the problem-based approach, I defined binary decision variables, constraints, and an objective function using optimvar, optimconstr, and optimexpr. The code works well, but I need guidance on how to transform this code into a solver-based format using intlinprog.
Here’s a summary of what I have:
Decision Variables:
A 3D binary matrix A(N, numNodes, num_vehicles) for task assignment.
A binary vector chi(num_vehicles) for satisfaction.
Other binary variables like z, t_wait_aux, etc.
Constraints:
Assignment constraints, dependency constraints, and time-based constraints.
I linearized expressions using auxiliary variables and max constraints.
Objective Function:
The objective is to maximize the satisfaction rate, expressed as a linear function of chi.
Could you provide guidance or directions how to systematically convert my existing problem-based variables and constraints into the matrix form required by intlinprog
Here is the code
the problem is attached.
Thank you for your continued help! Hello,
I have successfully implemented an ILP problem using MATLAB’s problem-based optimization approach. However, I am now looking to switch to the solver-based approach to take advantage of its flexibility and efficiency.
In the problem-based approach, I defined binary decision variables, constraints, and an objective function using optimvar, optimconstr, and optimexpr. The code works well, but I need guidance on how to transform this code into a solver-based format using intlinprog.
Here’s a summary of what I have:
Decision Variables:
A 3D binary matrix A(N, numNodes, num_vehicles) for task assignment.
A binary vector chi(num_vehicles) for satisfaction.
Other binary variables like z, t_wait_aux, etc.
Constraints:
Assignment constraints, dependency constraints, and time-based constraints.
I linearized expressions using auxiliary variables and max constraints.
Objective Function:
The objective is to maximize the satisfaction rate, expressed as a linear function of chi.
Could you provide guidance or directions how to systematically convert my existing problem-based variables and constraints into the matrix form required by intlinprog
Here is the code
the problem is attached.
Thank you for your continued help! solver based optimization, ilp, matlab code MATLAB Answers — New Questions
resize netcdf resolution to smaller size
Hi, I hope I can explain correctly.
I have data of size 649x337x268.
is it possible to resize it to 109x57x268?Hi, I hope I can explain correctly.
I have data of size 649x337x268.
is it possible to resize it to 109x57x268? Hi, I hope I can explain correctly.
I have data of size 649x337x268.
is it possible to resize it to 109x57x268? resize, resolution, nc file MATLAB Answers — New Questions
2D unsteady heat advection diffusion equation with Crank-Nicolson method scheme
how can i solve a 2D unsteady heat advection diffusion equation with Crank-Nicolson method scheme using Matlab? the convective flows are given by Taylor-Green vortex solution.how can i solve a 2D unsteady heat advection diffusion equation with Crank-Nicolson method scheme using Matlab? the convective flows are given by Taylor-Green vortex solution. how can i solve a 2D unsteady heat advection diffusion equation with Crank-Nicolson method scheme using Matlab? the convective flows are given by Taylor-Green vortex solution. crank-nicolson MATLAB Answers — New Questions
Simulink model -Code generation
Hello
I am currently trying to generate C++ code from a Simulink model (code only for grt.tlc system target file). The model includes some s-functions in which the mdlstart() functions are waiting for outside signal (TCP connexion).
I can’t send those signal during code generation. However, the code generation phases includes build and initialization steps. So then, initialization triggers mdlstart functions in s-function blocks.
Is there a way to avoid this intialization step during code generation (options in configuration parameters window)?
Thank youHello
I am currently trying to generate C++ code from a Simulink model (code only for grt.tlc system target file). The model includes some s-functions in which the mdlstart() functions are waiting for outside signal (TCP connexion).
I can’t send those signal during code generation. However, the code generation phases includes build and initialization steps. So then, initialization triggers mdlstart functions in s-function blocks.
Is there a way to avoid this intialization step during code generation (options in configuration parameters window)?
Thank you Hello
I am currently trying to generate C++ code from a Simulink model (code only for grt.tlc system target file). The model includes some s-functions in which the mdlstart() functions are waiting for outside signal (TCP connexion).
I can’t send those signal during code generation. However, the code generation phases includes build and initialization steps. So then, initialization triggers mdlstart functions in s-function blocks.
Is there a way to avoid this intialization step during code generation (options in configuration parameters window)?
Thank you simulink, code generation, s-function MATLAB Answers — New Questions
load mex library error on Linux
Hi,
I getting this error while trying to load a mex library on Ubuntu 20.04
>> loadlibrary(‘ice’, @iceproto)
Error using message/getString
In ‘MATLAB:loadlibrary:ErrorRunningFromCommandLine’, parameter {0} must be a real scalar.
Error in loadlibrary
I have build a mex, proto and thunk files
ice.mexa64 iceproto.m icethunk.so
Cheers,
JoseHi,
I getting this error while trying to load a mex library on Ubuntu 20.04
>> loadlibrary(‘ice’, @iceproto)
Error using message/getString
In ‘MATLAB:loadlibrary:ErrorRunningFromCommandLine’, parameter {0} must be a real scalar.
Error in loadlibrary
I have build a mex, proto and thunk files
ice.mexa64 iceproto.m icethunk.so
Cheers,
Jose Hi,
I getting this error while trying to load a mex library on Ubuntu 20.04
>> loadlibrary(‘ice’, @iceproto)
Error using message/getString
In ‘MATLAB:loadlibrary:ErrorRunningFromCommandLine’, parameter {0} must be a real scalar.
Error in loadlibrary
I have build a mex, proto and thunk files
ice.mexa64 iceproto.m icethunk.so
Cheers,
Jose mex MATLAB Answers — New Questions
Error using montage function
I have a script that, given 16 images,creates eight montages
I have read in the documentation that it is possible to use an handle to call the montage, and i have done that because i want to be able to show every single montage using imshow to be able to give titles to every one of them.
Running the script causes errors to occur.
Here is the script
clear all;
close all;
clc;
%Importare le immagini
%Posizioni centroidi
PosClust1=imread("Cent_col_cluster1.png");
PosClust2=imread("Cent_col_cluster2.png");
PosClust3=imread("Cent_col_cluster3.png");
PosClust4=imread("Cent_col_cluster4.png");
PosClust5=imread("Cent_col_cluster5.png");
PosClust6=imread("Cent_col_cluster6.png");
PosClust7=imread("Cent_col_cluster7.png");
PosClust8=imread("Cent_col_cluster8.png");
PosClust9=imread("Cent_col_cluster9.png");
%Colori centroidi
Cent_col_Clust1=imread("Cent_pos_cluster1.png");
Cent_col_Clust2=imread("Cent_pos_cluster2.png");
Cent_col_Clust3=imread("Cent_pos_cluster3.png");
Cent_col_Clust4=imread("Cent_pos_cluster4.png");
Cent_col_Clust5=imread("Cent_pos_cluster5.png");
Cent_col_Clust6=imread("Cent_pos_cluster6.png");
Cent_col_Clust7=imread("Cent_pos_cluster7.png");
Cent_col_Clust8=imread("Cent_pos_cluster8.png");
Cent_col_Clust9=imread("Cent_pos_cluster9.png");
%————————————————————————-
%Trasformazione in imagetipe double
%Posizioni centroidi
PosClust1Double=im2double(PosClust1);
PosClust2Double=im2double(PosClust2);
PosClust3Double=im2double(PosClust3);
PosClust4Double=im2double(PosClust4);
PosClust5Double=im2double(PosClust5);
PosClust6Double=im2double(PosClust6);
PosClust7Double=im2double(PosClust7);
PosClust8Double=im2double(PosClust8);
PosClust9Double=im2double(PosClust9);
%Colori centroidi
Cent_col_Clust1Double=im2double(Cent_col_Clust1);
Cent_col_Clust2Double=im2double(Cent_col_Clust2);
Cent_col_Clust3Double=im2double(Cent_col_Clust3);
Cent_col_Clust4Double=im2double(Cent_col_Clust4);
Cent_col_Clust5Double=im2double(Cent_col_Clust5);
Cent_col_Clust6Double=im2double(Cent_col_Clust6);
Cent_col_Clust7Double=im2double(Cent_col_Clust7);
Cent_col_Clust8Double=im2double(Cent_col_Clust8);
Cent_col_Clust9Double=im2double(Cent_col_Clust9);
%Creazione montaggi
Clust1=montage(Cent_col_Clust1Double,PosClust1Double);
Clust2=montage(Cent_col_Clust2Double,PosClust2Double);
Clust3=montage(Cent_col_Clust3Double,PosClust3Double);
Clust4=montage(Cent_col_Clust4Double,PosClust4Double);
Clust5=montage(Cent_col_Clust5Double,PosClust5Double);
Clust6=montage(Cent_col_Clust6Double,PosClust6Double);
Clust7=montage(Cent_col_Clust7Double,PosClust7Double);
Clust8=montage(Cent_col_Clust8Double,PosClust8Double);
Clust9=montage(Cent_col_Clust9Double,PosClust9Double);
%Plot
%Cluster1
imshow(Clust1)
title(‘Cluster1’)
%Cluster2
figure
imshow(Clust2)
title(‘Cluster2’)
%Cluster3
figure
imshow(Clust3)
title(‘Cluster3’)
%Cluster4
figure
imshow(Clust4)
title(‘Cluster4’)
%Cluster5
figure
imshow(Clust5)
title(‘Cluster5’)
%Cluster6
figure
imshow(Clust6)
title(‘Cluster6’)
%Cluster7
figure
imshow(Clust7)
title(‘Cluster7’)
%Cluster8
figure
imshow(Clust8)
title(‘Cluster8’)
%Cluster9
figure
imshow(Clust9)
title(‘Cluster9’)
These errors appear
Error using images.internal.imageDisplayParsePVPairs
Invalid input arguments.
Error in images.internal.imageDisplayParseInputs (line 70)
[common_args,specific_args] = images.internal.imageDisplayParsePVPairs(varargin{:});
Error in imshow (line 253)
images.internal.imageDisplayParseInputs({‘Parent’,’Border’,’Reduce’},preparsed_varargin{:});
Error in montage (line 231)
hh = imshow(bigImage,cmap,parentArgs{:},interpolationArgs{:});
Error in Montaggi_kmeans (line 52)
Clust1=montage(Cent_col_Clust1Double,PosClust1Double);
All Cent_col_Clust images are 420x560x3 uint8
All PosClust images are 595x842x3 uint8
All Cent_col_ClustDouble images are 420x560x3 double
All PosClustDouble images are 595x842x3 double
I have no clue what the problem is. Any ideas?
I cannot post all images, daily attachments limit is 10.I have a script that, given 16 images,creates eight montages
I have read in the documentation that it is possible to use an handle to call the montage, and i have done that because i want to be able to show every single montage using imshow to be able to give titles to every one of them.
Running the script causes errors to occur.
Here is the script
clear all;
close all;
clc;
%Importare le immagini
%Posizioni centroidi
PosClust1=imread("Cent_col_cluster1.png");
PosClust2=imread("Cent_col_cluster2.png");
PosClust3=imread("Cent_col_cluster3.png");
PosClust4=imread("Cent_col_cluster4.png");
PosClust5=imread("Cent_col_cluster5.png");
PosClust6=imread("Cent_col_cluster6.png");
PosClust7=imread("Cent_col_cluster7.png");
PosClust8=imread("Cent_col_cluster8.png");
PosClust9=imread("Cent_col_cluster9.png");
%Colori centroidi
Cent_col_Clust1=imread("Cent_pos_cluster1.png");
Cent_col_Clust2=imread("Cent_pos_cluster2.png");
Cent_col_Clust3=imread("Cent_pos_cluster3.png");
Cent_col_Clust4=imread("Cent_pos_cluster4.png");
Cent_col_Clust5=imread("Cent_pos_cluster5.png");
Cent_col_Clust6=imread("Cent_pos_cluster6.png");
Cent_col_Clust7=imread("Cent_pos_cluster7.png");
Cent_col_Clust8=imread("Cent_pos_cluster8.png");
Cent_col_Clust9=imread("Cent_pos_cluster9.png");
%————————————————————————-
%Trasformazione in imagetipe double
%Posizioni centroidi
PosClust1Double=im2double(PosClust1);
PosClust2Double=im2double(PosClust2);
PosClust3Double=im2double(PosClust3);
PosClust4Double=im2double(PosClust4);
PosClust5Double=im2double(PosClust5);
PosClust6Double=im2double(PosClust6);
PosClust7Double=im2double(PosClust7);
PosClust8Double=im2double(PosClust8);
PosClust9Double=im2double(PosClust9);
%Colori centroidi
Cent_col_Clust1Double=im2double(Cent_col_Clust1);
Cent_col_Clust2Double=im2double(Cent_col_Clust2);
Cent_col_Clust3Double=im2double(Cent_col_Clust3);
Cent_col_Clust4Double=im2double(Cent_col_Clust4);
Cent_col_Clust5Double=im2double(Cent_col_Clust5);
Cent_col_Clust6Double=im2double(Cent_col_Clust6);
Cent_col_Clust7Double=im2double(Cent_col_Clust7);
Cent_col_Clust8Double=im2double(Cent_col_Clust8);
Cent_col_Clust9Double=im2double(Cent_col_Clust9);
%Creazione montaggi
Clust1=montage(Cent_col_Clust1Double,PosClust1Double);
Clust2=montage(Cent_col_Clust2Double,PosClust2Double);
Clust3=montage(Cent_col_Clust3Double,PosClust3Double);
Clust4=montage(Cent_col_Clust4Double,PosClust4Double);
Clust5=montage(Cent_col_Clust5Double,PosClust5Double);
Clust6=montage(Cent_col_Clust6Double,PosClust6Double);
Clust7=montage(Cent_col_Clust7Double,PosClust7Double);
Clust8=montage(Cent_col_Clust8Double,PosClust8Double);
Clust9=montage(Cent_col_Clust9Double,PosClust9Double);
%Plot
%Cluster1
imshow(Clust1)
title(‘Cluster1’)
%Cluster2
figure
imshow(Clust2)
title(‘Cluster2’)
%Cluster3
figure
imshow(Clust3)
title(‘Cluster3’)
%Cluster4
figure
imshow(Clust4)
title(‘Cluster4’)
%Cluster5
figure
imshow(Clust5)
title(‘Cluster5’)
%Cluster6
figure
imshow(Clust6)
title(‘Cluster6’)
%Cluster7
figure
imshow(Clust7)
title(‘Cluster7’)
%Cluster8
figure
imshow(Clust8)
title(‘Cluster8’)
%Cluster9
figure
imshow(Clust9)
title(‘Cluster9’)
These errors appear
Error using images.internal.imageDisplayParsePVPairs
Invalid input arguments.
Error in images.internal.imageDisplayParseInputs (line 70)
[common_args,specific_args] = images.internal.imageDisplayParsePVPairs(varargin{:});
Error in imshow (line 253)
images.internal.imageDisplayParseInputs({‘Parent’,’Border’,’Reduce’},preparsed_varargin{:});
Error in montage (line 231)
hh = imshow(bigImage,cmap,parentArgs{:},interpolationArgs{:});
Error in Montaggi_kmeans (line 52)
Clust1=montage(Cent_col_Clust1Double,PosClust1Double);
All Cent_col_Clust images are 420x560x3 uint8
All PosClust images are 595x842x3 uint8
All Cent_col_ClustDouble images are 420x560x3 double
All PosClustDouble images are 595x842x3 double
I have no clue what the problem is. Any ideas?
I cannot post all images, daily attachments limit is 10. I have a script that, given 16 images,creates eight montages
I have read in the documentation that it is possible to use an handle to call the montage, and i have done that because i want to be able to show every single montage using imshow to be able to give titles to every one of them.
Running the script causes errors to occur.
Here is the script
clear all;
close all;
clc;
%Importare le immagini
%Posizioni centroidi
PosClust1=imread("Cent_col_cluster1.png");
PosClust2=imread("Cent_col_cluster2.png");
PosClust3=imread("Cent_col_cluster3.png");
PosClust4=imread("Cent_col_cluster4.png");
PosClust5=imread("Cent_col_cluster5.png");
PosClust6=imread("Cent_col_cluster6.png");
PosClust7=imread("Cent_col_cluster7.png");
PosClust8=imread("Cent_col_cluster8.png");
PosClust9=imread("Cent_col_cluster9.png");
%Colori centroidi
Cent_col_Clust1=imread("Cent_pos_cluster1.png");
Cent_col_Clust2=imread("Cent_pos_cluster2.png");
Cent_col_Clust3=imread("Cent_pos_cluster3.png");
Cent_col_Clust4=imread("Cent_pos_cluster4.png");
Cent_col_Clust5=imread("Cent_pos_cluster5.png");
Cent_col_Clust6=imread("Cent_pos_cluster6.png");
Cent_col_Clust7=imread("Cent_pos_cluster7.png");
Cent_col_Clust8=imread("Cent_pos_cluster8.png");
Cent_col_Clust9=imread("Cent_pos_cluster9.png");
%————————————————————————-
%Trasformazione in imagetipe double
%Posizioni centroidi
PosClust1Double=im2double(PosClust1);
PosClust2Double=im2double(PosClust2);
PosClust3Double=im2double(PosClust3);
PosClust4Double=im2double(PosClust4);
PosClust5Double=im2double(PosClust5);
PosClust6Double=im2double(PosClust6);
PosClust7Double=im2double(PosClust7);
PosClust8Double=im2double(PosClust8);
PosClust9Double=im2double(PosClust9);
%Colori centroidi
Cent_col_Clust1Double=im2double(Cent_col_Clust1);
Cent_col_Clust2Double=im2double(Cent_col_Clust2);
Cent_col_Clust3Double=im2double(Cent_col_Clust3);
Cent_col_Clust4Double=im2double(Cent_col_Clust4);
Cent_col_Clust5Double=im2double(Cent_col_Clust5);
Cent_col_Clust6Double=im2double(Cent_col_Clust6);
Cent_col_Clust7Double=im2double(Cent_col_Clust7);
Cent_col_Clust8Double=im2double(Cent_col_Clust8);
Cent_col_Clust9Double=im2double(Cent_col_Clust9);
%Creazione montaggi
Clust1=montage(Cent_col_Clust1Double,PosClust1Double);
Clust2=montage(Cent_col_Clust2Double,PosClust2Double);
Clust3=montage(Cent_col_Clust3Double,PosClust3Double);
Clust4=montage(Cent_col_Clust4Double,PosClust4Double);
Clust5=montage(Cent_col_Clust5Double,PosClust5Double);
Clust6=montage(Cent_col_Clust6Double,PosClust6Double);
Clust7=montage(Cent_col_Clust7Double,PosClust7Double);
Clust8=montage(Cent_col_Clust8Double,PosClust8Double);
Clust9=montage(Cent_col_Clust9Double,PosClust9Double);
%Plot
%Cluster1
imshow(Clust1)
title(‘Cluster1’)
%Cluster2
figure
imshow(Clust2)
title(‘Cluster2’)
%Cluster3
figure
imshow(Clust3)
title(‘Cluster3’)
%Cluster4
figure
imshow(Clust4)
title(‘Cluster4’)
%Cluster5
figure
imshow(Clust5)
title(‘Cluster5’)
%Cluster6
figure
imshow(Clust6)
title(‘Cluster6’)
%Cluster7
figure
imshow(Clust7)
title(‘Cluster7’)
%Cluster8
figure
imshow(Clust8)
title(‘Cluster8’)
%Cluster9
figure
imshow(Clust9)
title(‘Cluster9’)
These errors appear
Error using images.internal.imageDisplayParsePVPairs
Invalid input arguments.
Error in images.internal.imageDisplayParseInputs (line 70)
[common_args,specific_args] = images.internal.imageDisplayParsePVPairs(varargin{:});
Error in imshow (line 253)
images.internal.imageDisplayParseInputs({‘Parent’,’Border’,’Reduce’},preparsed_varargin{:});
Error in montage (line 231)
hh = imshow(bigImage,cmap,parentArgs{:},interpolationArgs{:});
Error in Montaggi_kmeans (line 52)
Clust1=montage(Cent_col_Clust1Double,PosClust1Double);
All Cent_col_Clust images are 420x560x3 uint8
All PosClust images are 595x842x3 uint8
All Cent_col_ClustDouble images are 420x560x3 double
All PosClustDouble images are 595x842x3 double
I have no clue what the problem is. Any ideas?
I cannot post all images, daily attachments limit is 10. montage, image processing, matlab function MATLAB Answers — New Questions
Simulink Embedded Coder Zero Initialization of Local Variables Not Working
Hello, I am using Embedded Coder on Simulink Model (MATLAB 2022B). I want Local variables of generated code to be initialized to zero. I already unticked ‘Remove root level I/O zero initialization’ and ‘Remove internal data zero initialization’ so code shouldn’t optimize initializations. These two settings initialize Global variables to zero, but don’t initialize Local variables to zero. There is an example of generated code and how I want it to be. How can I do it? Thanks for your help.
How it is:
void step_function(uint16_t in1, uint16_t in2)
{
uint16_t Divide;
uint16_t UnitDelay1;
…
How it should be:
void step_function(uint16_t in1, uint16_t in2)
{
uint16_t Divide = 0;
uint16_t UnitDelay1 = 0;
…Hello, I am using Embedded Coder on Simulink Model (MATLAB 2022B). I want Local variables of generated code to be initialized to zero. I already unticked ‘Remove root level I/O zero initialization’ and ‘Remove internal data zero initialization’ so code shouldn’t optimize initializations. These two settings initialize Global variables to zero, but don’t initialize Local variables to zero. There is an example of generated code and how I want it to be. How can I do it? Thanks for your help.
How it is:
void step_function(uint16_t in1, uint16_t in2)
{
uint16_t Divide;
uint16_t UnitDelay1;
…
How it should be:
void step_function(uint16_t in1, uint16_t in2)
{
uint16_t Divide = 0;
uint16_t UnitDelay1 = 0;
… Hello, I am using Embedded Coder on Simulink Model (MATLAB 2022B). I want Local variables of generated code to be initialized to zero. I already unticked ‘Remove root level I/O zero initialization’ and ‘Remove internal data zero initialization’ so code shouldn’t optimize initializations. These two settings initialize Global variables to zero, but don’t initialize Local variables to zero. There is an example of generated code and how I want it to be. How can I do it? Thanks for your help.
How it is:
void step_function(uint16_t in1, uint16_t in2)
{
uint16_t Divide;
uint16_t UnitDelay1;
…
How it should be:
void step_function(uint16_t in1, uint16_t in2)
{
uint16_t Divide = 0;
uint16_t UnitDelay1 = 0;
… embedded coder, code generation, simulink, zero initialization MATLAB Answers — New Questions
jsonencode not encoding entire large structure data
Hi
I have a large table converting to structure type and then use the jsonencode to encode the data.
However I realized that not all data has been converted to json, since the ending was not "]" or "}".
Is there a fail-safe way to convert large table to json?
Thanks,Hi
I have a large table converting to structure type and then use the jsonencode to encode the data.
However I realized that not all data has been converted to json, since the ending was not "]" or "}".
Is there a fail-safe way to convert large table to json?
Thanks, Hi
I have a large table converting to structure type and then use the jsonencode to encode the data.
However I realized that not all data has been converted to json, since the ending was not "]" or "}".
Is there a fail-safe way to convert large table to json?
Thanks, matlab MATLAB Answers — New Questions
Is the oscillation in the picture a boundary condition problem?
Hi,
I have an equation which is as follows
When I solve this equation using the pdepe it shows an oscillation pattern at the edge as it is here (shown by arrow).
I changed my parameters a lot but this oscillation sometime reduces, but not zero. My bc are as follows
pl = 0;
ql = 1;
pr = 0;
qr = 1;
Can you tell how to reduce this oscillations?
Also, in the above equation, for the diffusion coefficient (sigma) the minimum value for which the pdepe converges is 1 below which the solution becomes diverging, it should not be actually.
with regardsHi,
I have an equation which is as follows
When I solve this equation using the pdepe it shows an oscillation pattern at the edge as it is here (shown by arrow).
I changed my parameters a lot but this oscillation sometime reduces, but not zero. My bc are as follows
pl = 0;
ql = 1;
pr = 0;
qr = 1;
Can you tell how to reduce this oscillations?
Also, in the above equation, for the diffusion coefficient (sigma) the minimum value for which the pdepe converges is 1 below which the solution becomes diverging, it should not be actually.
with regards Hi,
I have an equation which is as follows
When I solve this equation using the pdepe it shows an oscillation pattern at the edge as it is here (shown by arrow).
I changed my parameters a lot but this oscillation sometime reduces, but not zero. My bc are as follows
pl = 0;
ql = 1;
pr = 0;
qr = 1;
Can you tell how to reduce this oscillations?
Also, in the above equation, for the diffusion coefficient (sigma) the minimum value for which the pdepe converges is 1 below which the solution becomes diverging, it should not be actually.
with regards pdepe MATLAB Answers — New Questions