Tag Archives: matlab
How to Access Enum Bus Signal in Variant Subsystem within Referenced Model?
Hello everyone,
I’m facing an issue with a Simulink model where I’m using an enum bus signal to switch between two models configured as variant subsystems. These variant subsystems are part of a referenced model.
The problem is that the models in the referenced subsystem don’t seem to have access to the enum bus signal or even to the base workspace variables.
I need the enum bus signal to be available in the referenced models so that it can control the variant conditions. Does anyone have suggestions on how to pass this enum bus signal to the referenced model or how to make it accessible within these models?
Any help or insight would be greatly appreciated!
Thanks in advance!Hello everyone,
I’m facing an issue with a Simulink model where I’m using an enum bus signal to switch between two models configured as variant subsystems. These variant subsystems are part of a referenced model.
The problem is that the models in the referenced subsystem don’t seem to have access to the enum bus signal or even to the base workspace variables.
I need the enum bus signal to be available in the referenced models so that it can control the variant conditions. Does anyone have suggestions on how to pass this enum bus signal to the referenced model or how to make it accessible within these models?
Any help or insight would be greatly appreciated!
Thanks in advance! Hello everyone,
I’m facing an issue with a Simulink model where I’m using an enum bus signal to switch between two models configured as variant subsystems. These variant subsystems are part of a referenced model.
The problem is that the models in the referenced subsystem don’t seem to have access to the enum bus signal or even to the base workspace variables.
I need the enum bus signal to be available in the referenced models so that it can control the variant conditions. Does anyone have suggestions on how to pass this enum bus signal to the referenced model or how to make it accessible within these models?
Any help or insight would be greatly appreciated!
Thanks in advance! variant subsystem, referenced model MATLAB Answers — New Questions
function “getFileInfoForToolstrip” endless loop
I use the cvx tool box in my code. "getFileInfoForToolstrip" function is called. And it become endless loop. It can’t jump out of this function. But this function is written by MathWorks, I am confuse how i can solve it?
Following is the function I copy from the function.
function [isTestFile, isValidFile, isClassBasedTest] = getFileInfoForToolstrip(file)
[SL: snipped the full body of the MathWorks function]I use the cvx tool box in my code. "getFileInfoForToolstrip" function is called. And it become endless loop. It can’t jump out of this function. But this function is written by MathWorks, I am confuse how i can solve it?
Following is the function I copy from the function.
function [isTestFile, isValidFile, isClassBasedTest] = getFileInfoForToolstrip(file)
[SL: snipped the full body of the MathWorks function] I use the cvx tool box in my code. "getFileInfoForToolstrip" function is called. And it become endless loop. It can’t jump out of this function. But this function is written by MathWorks, I am confuse how i can solve it?
Following is the function I copy from the function.
function [isTestFile, isValidFile, isClassBasedTest] = getFileInfoForToolstrip(file)
[SL: snipped the full body of the MathWorks function] convex, optimization, official function MATLAB Answers — New Questions
Must return a column vector error when using “ode45”
%% Clean the Workspace
clc
clear all
%% Format
format long
%% Variables
global m_ExtraSteam U0_shell V rho_0 U_steam
T0_shell = 105; % initial shell side temp, degC
P0_shell = 1.2; % initial pressure, bara
U0_shell = XSteam(‘uV_p’, P0_shell);
Plimit = 3.3; % max pressure, bara
MW = 0.018015; % kg/mol
R = 0.00008205736; % bar.m3/mol.K
V = 233.21; % m3
rho_0 = XSteam(‘rhoV_p’, P0_shell);
tb = 20; % Upper time interval limit
m_ExtraSteam = 35.08; % Flowrate of extra steam due to ST trip, kg/sec
t_interval = [0.001 tb]; % Time interval
%% Solve the DE
[tsol,Usol] = ode45(@(t, U_steam) cfunc(t, U_steam) , t_interval , U0_shell); % Temperature with time, degC
%% Dynamic Parameter Calculation
Ptube_in = 7;
Ptube_out = 6.5;
m_tube = [707.9 707.9 707.9 707.9];
T_tube_in = [91.7 91.7 91.7 91.7];
for m=1:lenght(Usol)
U_steam = Usol(m);
Tsol(m) = fsolve(@TfinderwU,100);
end
for p=5:length(Tsol)
T_tube_in(p) = 80.1;
m_tube(p) = 1131.2;
end
T_tube_out = 98;
for k = 1:length(Tsol)
deltaH_tube(k) = XSteam(‘h_pT’, Ptube_out, T_tube_out) – XSteam(‘h_pT’, Ptube_in, T_tube_in(k)); % Specific enthalpy difference between the inlet and outlet of the tube side, kJ/kg
if ((m_tube(k)*deltaH_tube(k))/(XSteam(‘hV_T’, Tsol(k)) – XSteam(‘hL_T’, Tsol(k)))) >= m_ExtraSteam
m_ExtraSteam_Condensation(k) = m_ExtraSteam;
else
m_ExtraSteam_Condensation(k) = (m_tube(k)*deltaH_tube(k))/(XSteam(‘hV_T’, Tsol(k)) – XSteam(‘hL_T’, Tsol(k)));
end
end
m_steam_accumulated = (m_ExtraSteam – m_ExtraSteam_Condensation)’; % Steam accumulated in the shell side, kg/sec
nfor(1) = m_steam_accumulated(1)*(tsol(1))/MW;
for k1 = 2:length(Tsol)
nfor(k1) = m_steam_accumulated(k1)*(tsol(k1)-tsol(k1-1))/MW;
end
%% Final Pressure Calculation
%% Plotting
figure(‘Name’,’Temperature, Pressure vs Time’,’NumberTitle’,’off’);
yyaxis left % subplot(1,2,1)
plot(tsol,Tsol)
xlabel(‘Time (s)’)
ylabel(‘Temperature (C)’)
yyaxis right % subplot(1,2,2)
plot(tsol,Psol)
xlabel(‘Time (s)’)
ylabel(‘Pressure (bara)’)
%% Display Results
fprintf(‘Max pressure during the observed time interval = %.3f bara.n’, max(Psol))
%% Functions
% Main Function
function dUdt = cfunc(t,U_steam)
% Variables
global m_ExtraSteam U0_shell V rho_0 U_steam
Ptube_in = 7;
Ptube_out = 6.5;
T_tube_out = 98;
if t<3.3
m_tube = 707.9;
T_tube_in = 91.7;
else
m_tube = 1131.2;
T_tube_in = 80.1;
end
% Find the Temp with Internal Energy
T = fsolve(@TfinderwU,100);
deltaH_tube = XSteam(‘h_pT’, Ptube_out, T_tube_out) – XSteam(‘h_pT’, Ptube_in, T_tube_in); % Specific enthalpy difference between the inlet and outlet of the tube side, kJ/kg
if ((m_tube*deltaH_tube)/(XSteam(‘hV_T’, T) – XSteam(‘hL_T’, T))) >= m_ExtraSteam
m_ExtraSteam_Condensation = m_ExtraSteam;
else
m_ExtraSteam_Condensation = (m_tube*deltaH_tube)/(XSteam(‘hV_T’, T) – XSteam(‘hL_T’, T));
end
m_steam_accumulated = m_ExtraSteam – m_ExtraSteam_Condensation; % Steam accumulated in the shell side, kg/sec
steam_mass = rho_0*V + m_steam_accumulated*t;
U_condensate = XSteam(‘uL_T’, T);
CpL = XSteam(‘CpL_T’, T);
Qcv = m_tube*CpL*(T_tube_out-T_tube_in);
% Differential Equation
dUdt = (-Qcv + m_ExtraSteam*U0_shell – m_ExtraSteam_Condensation*U_condensate – U_steam*m_steam_accumulated)/steam_mass;
end
% Temperature Finder Function with Internal Energy
function Obj = TfinderwU(T)
global U_steam
uV_T = XSteam(‘uV_T’, T);
Obj = U_steam- uV_T;
end%% Clean the Workspace
clc
clear all
%% Format
format long
%% Variables
global m_ExtraSteam U0_shell V rho_0 U_steam
T0_shell = 105; % initial shell side temp, degC
P0_shell = 1.2; % initial pressure, bara
U0_shell = XSteam(‘uV_p’, P0_shell);
Plimit = 3.3; % max pressure, bara
MW = 0.018015; % kg/mol
R = 0.00008205736; % bar.m3/mol.K
V = 233.21; % m3
rho_0 = XSteam(‘rhoV_p’, P0_shell);
tb = 20; % Upper time interval limit
m_ExtraSteam = 35.08; % Flowrate of extra steam due to ST trip, kg/sec
t_interval = [0.001 tb]; % Time interval
%% Solve the DE
[tsol,Usol] = ode45(@(t, U_steam) cfunc(t, U_steam) , t_interval , U0_shell); % Temperature with time, degC
%% Dynamic Parameter Calculation
Ptube_in = 7;
Ptube_out = 6.5;
m_tube = [707.9 707.9 707.9 707.9];
T_tube_in = [91.7 91.7 91.7 91.7];
for m=1:lenght(Usol)
U_steam = Usol(m);
Tsol(m) = fsolve(@TfinderwU,100);
end
for p=5:length(Tsol)
T_tube_in(p) = 80.1;
m_tube(p) = 1131.2;
end
T_tube_out = 98;
for k = 1:length(Tsol)
deltaH_tube(k) = XSteam(‘h_pT’, Ptube_out, T_tube_out) – XSteam(‘h_pT’, Ptube_in, T_tube_in(k)); % Specific enthalpy difference between the inlet and outlet of the tube side, kJ/kg
if ((m_tube(k)*deltaH_tube(k))/(XSteam(‘hV_T’, Tsol(k)) – XSteam(‘hL_T’, Tsol(k)))) >= m_ExtraSteam
m_ExtraSteam_Condensation(k) = m_ExtraSteam;
else
m_ExtraSteam_Condensation(k) = (m_tube(k)*deltaH_tube(k))/(XSteam(‘hV_T’, Tsol(k)) – XSteam(‘hL_T’, Tsol(k)));
end
end
m_steam_accumulated = (m_ExtraSteam – m_ExtraSteam_Condensation)’; % Steam accumulated in the shell side, kg/sec
nfor(1) = m_steam_accumulated(1)*(tsol(1))/MW;
for k1 = 2:length(Tsol)
nfor(k1) = m_steam_accumulated(k1)*(tsol(k1)-tsol(k1-1))/MW;
end
%% Final Pressure Calculation
%% Plotting
figure(‘Name’,’Temperature, Pressure vs Time’,’NumberTitle’,’off’);
yyaxis left % subplot(1,2,1)
plot(tsol,Tsol)
xlabel(‘Time (s)’)
ylabel(‘Temperature (C)’)
yyaxis right % subplot(1,2,2)
plot(tsol,Psol)
xlabel(‘Time (s)’)
ylabel(‘Pressure (bara)’)
%% Display Results
fprintf(‘Max pressure during the observed time interval = %.3f bara.n’, max(Psol))
%% Functions
% Main Function
function dUdt = cfunc(t,U_steam)
% Variables
global m_ExtraSteam U0_shell V rho_0 U_steam
Ptube_in = 7;
Ptube_out = 6.5;
T_tube_out = 98;
if t<3.3
m_tube = 707.9;
T_tube_in = 91.7;
else
m_tube = 1131.2;
T_tube_in = 80.1;
end
% Find the Temp with Internal Energy
T = fsolve(@TfinderwU,100);
deltaH_tube = XSteam(‘h_pT’, Ptube_out, T_tube_out) – XSteam(‘h_pT’, Ptube_in, T_tube_in); % Specific enthalpy difference between the inlet and outlet of the tube side, kJ/kg
if ((m_tube*deltaH_tube)/(XSteam(‘hV_T’, T) – XSteam(‘hL_T’, T))) >= m_ExtraSteam
m_ExtraSteam_Condensation = m_ExtraSteam;
else
m_ExtraSteam_Condensation = (m_tube*deltaH_tube)/(XSteam(‘hV_T’, T) – XSteam(‘hL_T’, T));
end
m_steam_accumulated = m_ExtraSteam – m_ExtraSteam_Condensation; % Steam accumulated in the shell side, kg/sec
steam_mass = rho_0*V + m_steam_accumulated*t;
U_condensate = XSteam(‘uL_T’, T);
CpL = XSteam(‘CpL_T’, T);
Qcv = m_tube*CpL*(T_tube_out-T_tube_in);
% Differential Equation
dUdt = (-Qcv + m_ExtraSteam*U0_shell – m_ExtraSteam_Condensation*U_condensate – U_steam*m_steam_accumulated)/steam_mass;
end
% Temperature Finder Function with Internal Energy
function Obj = TfinderwU(T)
global U_steam
uV_T = XSteam(‘uV_T’, T);
Obj = U_steam- uV_T;
end %% Clean the Workspace
clc
clear all
%% Format
format long
%% Variables
global m_ExtraSteam U0_shell V rho_0 U_steam
T0_shell = 105; % initial shell side temp, degC
P0_shell = 1.2; % initial pressure, bara
U0_shell = XSteam(‘uV_p’, P0_shell);
Plimit = 3.3; % max pressure, bara
MW = 0.018015; % kg/mol
R = 0.00008205736; % bar.m3/mol.K
V = 233.21; % m3
rho_0 = XSteam(‘rhoV_p’, P0_shell);
tb = 20; % Upper time interval limit
m_ExtraSteam = 35.08; % Flowrate of extra steam due to ST trip, kg/sec
t_interval = [0.001 tb]; % Time interval
%% Solve the DE
[tsol,Usol] = ode45(@(t, U_steam) cfunc(t, U_steam) , t_interval , U0_shell); % Temperature with time, degC
%% Dynamic Parameter Calculation
Ptube_in = 7;
Ptube_out = 6.5;
m_tube = [707.9 707.9 707.9 707.9];
T_tube_in = [91.7 91.7 91.7 91.7];
for m=1:lenght(Usol)
U_steam = Usol(m);
Tsol(m) = fsolve(@TfinderwU,100);
end
for p=5:length(Tsol)
T_tube_in(p) = 80.1;
m_tube(p) = 1131.2;
end
T_tube_out = 98;
for k = 1:length(Tsol)
deltaH_tube(k) = XSteam(‘h_pT’, Ptube_out, T_tube_out) – XSteam(‘h_pT’, Ptube_in, T_tube_in(k)); % Specific enthalpy difference between the inlet and outlet of the tube side, kJ/kg
if ((m_tube(k)*deltaH_tube(k))/(XSteam(‘hV_T’, Tsol(k)) – XSteam(‘hL_T’, Tsol(k)))) >= m_ExtraSteam
m_ExtraSteam_Condensation(k) = m_ExtraSteam;
else
m_ExtraSteam_Condensation(k) = (m_tube(k)*deltaH_tube(k))/(XSteam(‘hV_T’, Tsol(k)) – XSteam(‘hL_T’, Tsol(k)));
end
end
m_steam_accumulated = (m_ExtraSteam – m_ExtraSteam_Condensation)’; % Steam accumulated in the shell side, kg/sec
nfor(1) = m_steam_accumulated(1)*(tsol(1))/MW;
for k1 = 2:length(Tsol)
nfor(k1) = m_steam_accumulated(k1)*(tsol(k1)-tsol(k1-1))/MW;
end
%% Final Pressure Calculation
%% Plotting
figure(‘Name’,’Temperature, Pressure vs Time’,’NumberTitle’,’off’);
yyaxis left % subplot(1,2,1)
plot(tsol,Tsol)
xlabel(‘Time (s)’)
ylabel(‘Temperature (C)’)
yyaxis right % subplot(1,2,2)
plot(tsol,Psol)
xlabel(‘Time (s)’)
ylabel(‘Pressure (bara)’)
%% Display Results
fprintf(‘Max pressure during the observed time interval = %.3f bara.n’, max(Psol))
%% Functions
% Main Function
function dUdt = cfunc(t,U_steam)
% Variables
global m_ExtraSteam U0_shell V rho_0 U_steam
Ptube_in = 7;
Ptube_out = 6.5;
T_tube_out = 98;
if t<3.3
m_tube = 707.9;
T_tube_in = 91.7;
else
m_tube = 1131.2;
T_tube_in = 80.1;
end
% Find the Temp with Internal Energy
T = fsolve(@TfinderwU,100);
deltaH_tube = XSteam(‘h_pT’, Ptube_out, T_tube_out) – XSteam(‘h_pT’, Ptube_in, T_tube_in); % Specific enthalpy difference between the inlet and outlet of the tube side, kJ/kg
if ((m_tube*deltaH_tube)/(XSteam(‘hV_T’, T) – XSteam(‘hL_T’, T))) >= m_ExtraSteam
m_ExtraSteam_Condensation = m_ExtraSteam;
else
m_ExtraSteam_Condensation = (m_tube*deltaH_tube)/(XSteam(‘hV_T’, T) – XSteam(‘hL_T’, T));
end
m_steam_accumulated = m_ExtraSteam – m_ExtraSteam_Condensation; % Steam accumulated in the shell side, kg/sec
steam_mass = rho_0*V + m_steam_accumulated*t;
U_condensate = XSteam(‘uL_T’, T);
CpL = XSteam(‘CpL_T’, T);
Qcv = m_tube*CpL*(T_tube_out-T_tube_in);
% Differential Equation
dUdt = (-Qcv + m_ExtraSteam*U0_shell – m_ExtraSteam_Condensation*U_condensate – U_steam*m_steam_accumulated)/steam_mass;
end
% Temperature Finder Function with Internal Energy
function Obj = TfinderwU(T)
global U_steam
uV_T = XSteam(‘uV_T’, T);
Obj = U_steam- uV_T;
end ode45, function, error MATLAB Answers — New Questions
how to write objective function
i want to pso algorithm on svr model ,as far as i know i need to write objective function in first code and determine other parameter to rest.
i got the objective function svr but i don’t know how to write that i used it in my pso algorithm then i found optimaziton of costfunction and penalty factor and insensitive lossi want to pso algorithm on svr model ,as far as i know i need to write objective function in first code and determine other parameter to rest.
i got the objective function svr but i don’t know how to write that i used it in my pso algorithm then i found optimaziton of costfunction and penalty factor and insensitive loss i want to pso algorithm on svr model ,as far as i know i need to write objective function in first code and determine other parameter to rest.
i got the objective function svr but i don’t know how to write that i used it in my pso algorithm then i found optimaziton of costfunction and penalty factor and insensitive loss svr, pso MATLAB Answers — New Questions
Optimization with 3 variables- how to find the values of each variable to minimize mass?
I have an infrastructure where a metal sheet must be produced. An excavator, an electrolysis reactor, and a 3D printer must be used.
All this has to be performed in 3650 days. So, I am trying to kind of optimize it and find how many excavators, reactors, and 3D printers will give the smallest mass but will also be able to get the job done in 3650 days. I am not sure if and how a code can be written for that. Any help would be appreciated.
days_req=3650; %
m_sheet=linspace(100,10000,200); % mass of a metal sheet
% excavator
n_excav=1:1:200; % number of excavators
m_excav=67; % mass of each excavator
m_tot_excav=n_RASSORs*m_RASSOR; % mass for n excavators
excav_cap=n_excav*6536; % kg/day
days_excav=ceil(m_sheet./excav_cap./n_excav); % days to excavate
% electrolysis reactor
n_react=1:1:200; % number of reactors
m_react=2000; % mass of each reactor
m_tot_react=n_react*m_react; % mass for n reactors
prod_rate_react=7*24; % kg/day of regolith
days_react=ceil(m_sheet./prod_rate_react./n_react); % days to process m_sheet
% printer
n_printer=1:1:200; % number of printers
m_printer=3500; % mass of each printer
m_tot_printer=n_printer*m_printer; % mass for n printers
deposition_rate=n_printer*14.4; % kg/day
days_print=ceil(m_sheet./deposition_rate./n_printer); % days to printI have an infrastructure where a metal sheet must be produced. An excavator, an electrolysis reactor, and a 3D printer must be used.
All this has to be performed in 3650 days. So, I am trying to kind of optimize it and find how many excavators, reactors, and 3D printers will give the smallest mass but will also be able to get the job done in 3650 days. I am not sure if and how a code can be written for that. Any help would be appreciated.
days_req=3650; %
m_sheet=linspace(100,10000,200); % mass of a metal sheet
% excavator
n_excav=1:1:200; % number of excavators
m_excav=67; % mass of each excavator
m_tot_excav=n_RASSORs*m_RASSOR; % mass for n excavators
excav_cap=n_excav*6536; % kg/day
days_excav=ceil(m_sheet./excav_cap./n_excav); % days to excavate
% electrolysis reactor
n_react=1:1:200; % number of reactors
m_react=2000; % mass of each reactor
m_tot_react=n_react*m_react; % mass for n reactors
prod_rate_react=7*24; % kg/day of regolith
days_react=ceil(m_sheet./prod_rate_react./n_react); % days to process m_sheet
% printer
n_printer=1:1:200; % number of printers
m_printer=3500; % mass of each printer
m_tot_printer=n_printer*m_printer; % mass for n printers
deposition_rate=n_printer*14.4; % kg/day
days_print=ceil(m_sheet./deposition_rate./n_printer); % days to print I have an infrastructure where a metal sheet must be produced. An excavator, an electrolysis reactor, and a 3D printer must be used.
All this has to be performed in 3650 days. So, I am trying to kind of optimize it and find how many excavators, reactors, and 3D printers will give the smallest mass but will also be able to get the job done in 3650 days. I am not sure if and how a code can be written for that. Any help would be appreciated.
days_req=3650; %
m_sheet=linspace(100,10000,200); % mass of a metal sheet
% excavator
n_excav=1:1:200; % number of excavators
m_excav=67; % mass of each excavator
m_tot_excav=n_RASSORs*m_RASSOR; % mass for n excavators
excav_cap=n_excav*6536; % kg/day
days_excav=ceil(m_sheet./excav_cap./n_excav); % days to excavate
% electrolysis reactor
n_react=1:1:200; % number of reactors
m_react=2000; % mass of each reactor
m_tot_react=n_react*m_react; % mass for n reactors
prod_rate_react=7*24; % kg/day of regolith
days_react=ceil(m_sheet./prod_rate_react./n_react); % days to process m_sheet
% printer
n_printer=1:1:200; % number of printers
m_printer=3500; % mass of each printer
m_tot_printer=n_printer*m_printer; % mass for n printers
deposition_rate=n_printer*14.4; % kg/day
days_print=ceil(m_sheet./deposition_rate./n_printer); % days to print optimization MATLAB Answers — New Questions
For Loop to Cycle through Struct
I have a 6×1 struct and want to create a for loop that will cycle through and pull out the name field of the 1×1 struct.
How can I do that? ** I am using R2012a **
I apologize for the strange format, the toolbar at the top of the body is missing and I’m still trying to fix it.I have a 6×1 struct and want to create a for loop that will cycle through and pull out the name field of the 1×1 struct.
How can I do that? ** I am using R2012a **
I apologize for the strange format, the toolbar at the top of the body is missing and I’m still trying to fix it. I have a 6×1 struct and want to create a for loop that will cycle through and pull out the name field of the 1×1 struct.
How can I do that? ** I am using R2012a **
I apologize for the strange format, the toolbar at the top of the body is missing and I’m still trying to fix it. struct, fieldname MATLAB Answers — New Questions
Error while loading the old session in PIVlab (the GUI says loading session but it never loads)
Post Content Post Content pivlab, piv MATLAB Answers — New Questions
A problem about implementing soft-decision decode in an OFDM system
Hello,everyone. Recently I am working on a project of simulating a whole OFDM system.
I have made some progress. Now I want to change me (2,1,7) convolutional code – hard decode to soft-decision decode in order to get a better performance. I have learned from the matlab example how to implement soft-decision decode in an AWGN channel. But now I also want to apply it to a fast and multi-path fading channel. As a result of that, I am not sure about the value of noise power when calculate LLR.
I first pass my signal to a fading channel by using comm.RayleighChannel() , then I add noise by using awgn() block. This will give a noise power value.
[y_re,noise_var]=awgn(x_tr,SNR_dB(i),’measured’);
Then I do LS channel estimation and equalization at the receiver. This will change the value of the signal, so as the value of the noise. So I also calculate the noise power at this time.
noise_var_1= 10^(-SNR_dB(i)/10)* mean(Y_equalized.*conj(Y_equalized));
The two power values will be totally different since one is computed with the channel effect and one is not (with channel equalization). So wich value should I use to calculate LLR?
Thanks for your reading and hope you have some ideas about this question.Hello,everyone. Recently I am working on a project of simulating a whole OFDM system.
I have made some progress. Now I want to change me (2,1,7) convolutional code – hard decode to soft-decision decode in order to get a better performance. I have learned from the matlab example how to implement soft-decision decode in an AWGN channel. But now I also want to apply it to a fast and multi-path fading channel. As a result of that, I am not sure about the value of noise power when calculate LLR.
I first pass my signal to a fading channel by using comm.RayleighChannel() , then I add noise by using awgn() block. This will give a noise power value.
[y_re,noise_var]=awgn(x_tr,SNR_dB(i),’measured’);
Then I do LS channel estimation and equalization at the receiver. This will change the value of the signal, so as the value of the noise. So I also calculate the noise power at this time.
noise_var_1= 10^(-SNR_dB(i)/10)* mean(Y_equalized.*conj(Y_equalized));
The two power values will be totally different since one is computed with the channel effect and one is not (with channel equalization). So wich value should I use to calculate LLR?
Thanks for your reading and hope you have some ideas about this question. Hello,everyone. Recently I am working on a project of simulating a whole OFDM system.
I have made some progress. Now I want to change me (2,1,7) convolutional code – hard decode to soft-decision decode in order to get a better performance. I have learned from the matlab example how to implement soft-decision decode in an AWGN channel. But now I also want to apply it to a fast and multi-path fading channel. As a result of that, I am not sure about the value of noise power when calculate LLR.
I first pass my signal to a fading channel by using comm.RayleighChannel() , then I add noise by using awgn() block. This will give a noise power value.
[y_re,noise_var]=awgn(x_tr,SNR_dB(i),’measured’);
Then I do LS channel estimation and equalization at the receiver. This will change the value of the signal, so as the value of the noise. So I also calculate the noise power at this time.
noise_var_1= 10^(-SNR_dB(i)/10)* mean(Y_equalized.*conj(Y_equalized));
The two power values will be totally different since one is computed with the channel effect and one is not (with channel equalization). So wich value should I use to calculate LLR?
Thanks for your reading and hope you have some ideas about this question. ofdm, soft-decison decode MATLAB Answers — New Questions
Filtering multiple .csv files based on data from a table
Hello all,
I am trying to filter multiple .csv files (based on data in a separate table. To be more specific I am trying to filter the data from dataTables by "d_Data.Actual.Calculated_Flow" variable, so that it filters the data that are below minFlow or above maxFlow, which are listed in dataList. dataList has several columns the first one lists Tablename that corresponds with names of the tables in dataTables, the 4th & 5th lists corresponding maxFlow & minFlow that I would like to apply for filtering. How can I achieve this?
here is the code:
dataListDir="zoznam_merani.xlsx";
dataDir=’C:UsersU430746OneDrive – DanfossDesktopEHAEHA 1MatlabMatlabSimulation EHA V1Test DataOneDrive_2024-08-16Flow controlEHA_Flow_Control_standard modeEHA_Flow_Control’;
% Loads dataList
dataList=readtable(dataListDir);
% Loads direction to .csv files
dataFiles = dir(fullfile(dataDir, ‘*.csv’));
% Inicialize a cell array for input of tables
dataTables = cell(1, length(dataFiles));
% Loads tables to the dataTables cell array
for i = 1:length(dataFiles)
fileName = fullfile(dataDir, dataFiles(i).name);
dataTables{i} = readtable(fileName,"VariableNamingRule","preserve");
end
% Inicialize a cell array for filtered data
filteredDataTables = cell(1, length(dataFiles));
% Runs through all the tables in dataTables
for i = 1:length(dataTables)
% Finds a row that corresponds with the TableName
rowIndex = strcmp(dataList.TableName, dataFiles(i).name);
if any(rowIndex)
% Gets minFlow & maxFlow for the actual table
minFlow = dataList.minFlow(rowIndex);
maxFlow = dataList.maxFlow(rowIndex);
% Filters the tables based on minFlow & maxFlow
filteredDataTables{i} = dataTables{i}(dataTables{i}.("d_Data.Actual.Calculated_Flow") >= minFlow & dataTables{i}.("d_Data.Actual.Calculated_Flow") <= maxFlow, :);
else
% If the tableName is not available executes no changes
filteredDataTables{i} = dataTables{i};
end
endHello all,
I am trying to filter multiple .csv files (based on data in a separate table. To be more specific I am trying to filter the data from dataTables by "d_Data.Actual.Calculated_Flow" variable, so that it filters the data that are below minFlow or above maxFlow, which are listed in dataList. dataList has several columns the first one lists Tablename that corresponds with names of the tables in dataTables, the 4th & 5th lists corresponding maxFlow & minFlow that I would like to apply for filtering. How can I achieve this?
here is the code:
dataListDir="zoznam_merani.xlsx";
dataDir=’C:UsersU430746OneDrive – DanfossDesktopEHAEHA 1MatlabMatlabSimulation EHA V1Test DataOneDrive_2024-08-16Flow controlEHA_Flow_Control_standard modeEHA_Flow_Control’;
% Loads dataList
dataList=readtable(dataListDir);
% Loads direction to .csv files
dataFiles = dir(fullfile(dataDir, ‘*.csv’));
% Inicialize a cell array for input of tables
dataTables = cell(1, length(dataFiles));
% Loads tables to the dataTables cell array
for i = 1:length(dataFiles)
fileName = fullfile(dataDir, dataFiles(i).name);
dataTables{i} = readtable(fileName,"VariableNamingRule","preserve");
end
% Inicialize a cell array for filtered data
filteredDataTables = cell(1, length(dataFiles));
% Runs through all the tables in dataTables
for i = 1:length(dataTables)
% Finds a row that corresponds with the TableName
rowIndex = strcmp(dataList.TableName, dataFiles(i).name);
if any(rowIndex)
% Gets minFlow & maxFlow for the actual table
minFlow = dataList.minFlow(rowIndex);
maxFlow = dataList.maxFlow(rowIndex);
% Filters the tables based on minFlow & maxFlow
filteredDataTables{i} = dataTables{i}(dataTables{i}.("d_Data.Actual.Calculated_Flow") >= minFlow & dataTables{i}.("d_Data.Actual.Calculated_Flow") <= maxFlow, :);
else
% If the tableName is not available executes no changes
filteredDataTables{i} = dataTables{i};
end
end Hello all,
I am trying to filter multiple .csv files (based on data in a separate table. To be more specific I am trying to filter the data from dataTables by "d_Data.Actual.Calculated_Flow" variable, so that it filters the data that are below minFlow or above maxFlow, which are listed in dataList. dataList has several columns the first one lists Tablename that corresponds with names of the tables in dataTables, the 4th & 5th lists corresponding maxFlow & minFlow that I would like to apply for filtering. How can I achieve this?
here is the code:
dataListDir="zoznam_merani.xlsx";
dataDir=’C:UsersU430746OneDrive – DanfossDesktopEHAEHA 1MatlabMatlabSimulation EHA V1Test DataOneDrive_2024-08-16Flow controlEHA_Flow_Control_standard modeEHA_Flow_Control’;
% Loads dataList
dataList=readtable(dataListDir);
% Loads direction to .csv files
dataFiles = dir(fullfile(dataDir, ‘*.csv’));
% Inicialize a cell array for input of tables
dataTables = cell(1, length(dataFiles));
% Loads tables to the dataTables cell array
for i = 1:length(dataFiles)
fileName = fullfile(dataDir, dataFiles(i).name);
dataTables{i} = readtable(fileName,"VariableNamingRule","preserve");
end
% Inicialize a cell array for filtered data
filteredDataTables = cell(1, length(dataFiles));
% Runs through all the tables in dataTables
for i = 1:length(dataTables)
% Finds a row that corresponds with the TableName
rowIndex = strcmp(dataList.TableName, dataFiles(i).name);
if any(rowIndex)
% Gets minFlow & maxFlow for the actual table
minFlow = dataList.minFlow(rowIndex);
maxFlow = dataList.maxFlow(rowIndex);
% Filters the tables based on minFlow & maxFlow
filteredDataTables{i} = dataTables{i}(dataTables{i}.("d_Data.Actual.Calculated_Flow") >= minFlow & dataTables{i}.("d_Data.Actual.Calculated_Flow") <= maxFlow, :);
else
% If the tableName is not available executes no changes
filteredDataTables{i} = dataTables{i};
end
end filter, csv, cell array, multiple tables, multiple MATLAB Answers — New Questions
Why is the preprocessor check #if ( UCHAR_MAX != (0xFFU) ) || ( SCHAR_MAX != (0x7F) ) being generated in private.h?
In the generated code for my model, I have noticed that the following code is generated in the "model_private.h" file:
#if ( UCHAR_MAX != (0xFFU) ) || ( SCHAR_MAX != (0x7F) )
#error Code was generated for compiler with different sized uchar/char.
Consider adjusting Test hardware word size settings on the
Hardware Implementation pane to match your compiler word sizes as
defined in limits.h of the compiler. Alternatively, you can
select the Test hardware is the same as production hardware option and
select the Enable portable word sizes option on the Code Generation >
Verification pane for ERT based targets, which will disable the
preprocessor word size checks.
#endif
Why is this code being generated?In the generated code for my model, I have noticed that the following code is generated in the "model_private.h" file:
#if ( UCHAR_MAX != (0xFFU) ) || ( SCHAR_MAX != (0x7F) )
#error Code was generated for compiler with different sized uchar/char.
Consider adjusting Test hardware word size settings on the
Hardware Implementation pane to match your compiler word sizes as
defined in limits.h of the compiler. Alternatively, you can
select the Test hardware is the same as production hardware option and
select the Enable portable word sizes option on the Code Generation >
Verification pane for ERT based targets, which will disable the
preprocessor word size checks.
#endif
Why is this code being generated? In the generated code for my model, I have noticed that the following code is generated in the "model_private.h" file:
#if ( UCHAR_MAX != (0xFFU) ) || ( SCHAR_MAX != (0x7F) )
#error Code was generated for compiler with different sized uchar/char.
Consider adjusting Test hardware word size settings on the
Hardware Implementation pane to match your compiler word sizes as
defined in limits.h of the compiler. Alternatively, you can
select the Test hardware is the same as production hardware option and
select the Enable portable word sizes option on the Code Generation >
Verification pane for ERT based targets, which will disable the
preprocessor word size checks.
#endif
Why is this code being generated? fixedpoint, codegen, header, check, limit MATLAB Answers — New Questions
how to create a histogram for featim?
hi matlab community, is something wrong with my coding below? i want to create a histogram for featim. thnkyou so much.
feat=zeros(982,40);
for k=1:982
A=FYPdatabase{k,1};
featim=gmlog(A);
FYPdatabase{k,5}=featim;
end
hist3(featim);hi matlab community, is something wrong with my coding below? i want to create a histogram for featim. thnkyou so much.
feat=zeros(982,40);
for k=1:982
A=FYPdatabase{k,1};
featim=gmlog(A);
FYPdatabase{k,5}=featim;
end
hist3(featim); hi matlab community, is something wrong with my coding below? i want to create a histogram for featim. thnkyou so much.
feat=zeros(982,40);
for k=1:982
A=FYPdatabase{k,1};
featim=gmlog(A);
FYPdatabase{k,5}=featim;
end
hist3(featim); image processing MATLAB Answers — New Questions
Halo i want to combine 2d slices oct skin images into 3d, after that i want to make an automatic detection volume of epidermis and stratum corneum
i already combine like this
% Initialize variables
rows = []; columns = [];
% Loop through each slice
for k = 1:100
fileName = sprintf(‘_%d.txt’, k);
% Read the text file
sliceImage = dlmread(fileName);
% Check the size of the first slice to initialize the 3D array
if isempty(rows) || isempty(columns)
[rows, columns] = size(sliceImage);
image3d = zeros(rows, columns, 8, ‘uint8’); % Initialize 3D array
end
% Convert to uint8
sliceImage = uint8(sliceImage);
% Put this slice into plane k of the 3D image
image3d(:, :, k) = sliceImage;
endi already combine like this
% Initialize variables
rows = []; columns = [];
% Loop through each slice
for k = 1:100
fileName = sprintf(‘_%d.txt’, k);
% Read the text file
sliceImage = dlmread(fileName);
% Check the size of the first slice to initialize the 3D array
if isempty(rows) || isempty(columns)
[rows, columns] = size(sliceImage);
image3d = zeros(rows, columns, 8, ‘uint8’); % Initialize 3D array
end
% Convert to uint8
sliceImage = uint8(sliceImage);
% Put this slice into plane k of the 3D image
image3d(:, :, k) = sliceImage;
end i already combine like this
% Initialize variables
rows = []; columns = [];
% Loop through each slice
for k = 1:100
fileName = sprintf(‘_%d.txt’, k);
% Read the text file
sliceImage = dlmread(fileName);
% Check the size of the first slice to initialize the 3D array
if isempty(rows) || isempty(columns)
[rows, columns] = size(sliceImage);
image3d = zeros(rows, columns, 8, ‘uint8’); % Initialize 3D array
end
% Convert to uint8
sliceImage = uint8(sliceImage);
% Put this slice into plane k of the 3D image
image3d(:, :, k) = sliceImage;
end 3d plots, image segmentation MATLAB Answers — New Questions
how to export model coordinates?
Hello,
I am running the example spiralInductor.
Is there a way to export the geometry for fabrication?
Thank youHello,
I am running the example spiralInductor.
Is there a way to export the geometry for fabrication?
Thank you Hello,
I am running the example spiralInductor.
Is there a way to export the geometry for fabrication?
Thank you coil, matlab coder, microwave, performance MATLAB Answers — New Questions
Remogenerate optimized code by removing code for out-of-range floating point to integer conversions did not improve execution speed,is there a problem?
I want to improve the running speed of the code converted from Simulink to C coder, so I tried setting the maximum running speed mode in it, but the result was similar to balancing RAM and speed mode. So I tried to modify more detailed settings, I tried to modify the settings to regenerate optimized code by removing out of range floating-point to integer conversion code, but still had no effect. Why is this? Is there any other setting in the model that can improve the running speed of the code? Or should I directly modify the structure of the code to improve speed?I want to improve the running speed of the code converted from Simulink to C coder, so I tried setting the maximum running speed mode in it, but the result was similar to balancing RAM and speed mode. So I tried to modify more detailed settings, I tried to modify the settings to regenerate optimized code by removing out of range floating-point to integer conversion code, but still had no effect. Why is this? Is there any other setting in the model that can improve the running speed of the code? Or should I directly modify the structure of the code to improve speed? I want to improve the running speed of the code converted from Simulink to C coder, so I tried setting the maximum running speed mode in it, but the result was similar to balancing RAM and speed mode. So I tried to modify more detailed settings, I tried to modify the settings to regenerate optimized code by removing out of range floating-point to integer conversion code, but still had no effect. Why is this? Is there any other setting in the model that can improve the running speed of the code? Or should I directly modify the structure of the code to improve speed? simulink, embedded coder MATLAB Answers — New Questions
How to average across tables in a cell
I have a Cell containing a n number of tables (in this case 3 tables (2500×44)) and I’m trying output just one table being the average of each cell within each table across all 3 tables. This is likely a silly question but can’t seem to figure it out.I have a Cell containing a n number of tables (in this case 3 tables (2500×44)) and I’m trying output just one table being the average of each cell within each table across all 3 tables. This is likely a silly question but can’t seem to figure it out. I have a Cell containing a n number of tables (in this case 3 tables (2500×44)) and I’m trying output just one table being the average of each cell within each table across all 3 tables. This is likely a silly question but can’t seem to figure it out. cell array, table, mean MATLAB Answers — New Questions
Why there is a time delay of one time step while co-simulating a FMU in Simulink?
I exported an FMU from a Simulink model with Simulink Compiler and imported it into Simulink with FMU Import block.
In the results, when comparing the Simulink output and the FMU output, I see that they do not match with a one-time step difference/one-time step delay.
What is causing this behavior?I exported an FMU from a Simulink model with Simulink Compiler and imported it into Simulink with FMU Import block.
In the results, when comparing the Simulink output and the FMU output, I see that they do not match with a one-time step difference/one-time step delay.
What is causing this behavior? I exported an FMU from a Simulink model with Simulink Compiler and imported it into Simulink with FMU Import block.
In the results, when comparing the Simulink output and the FMU output, I see that they do not match with a one-time step difference/one-time step delay.
What is causing this behavior? fmu, delay, time, step, different, results, simulink, fmi MATLAB Answers — New Questions
Interpolating between columns for an index
I am trying to use a seperate array as an index and a variable.
E.g.
Row 1 I want to use as index, or lookup.
Row 2 are data
550 750 950
1 2 8
Column 1 would be reference from row 1
Column 2 would be multiplied against row 2 depending on how Column 1 relates to row 1
550 22
580 21
650 20
623 28
850 14
So my goal is using the second set of data.
at 550, 22 would be multiplied by 1,
at 650, 20 would be multiplied by 1.5
at 850, 14 would be multiplied by 5
I tried search for awhile on the community and through the "basics"
I might be wording this wrong by calling it indexing.I am trying to use a seperate array as an index and a variable.
E.g.
Row 1 I want to use as index, or lookup.
Row 2 are data
550 750 950
1 2 8
Column 1 would be reference from row 1
Column 2 would be multiplied against row 2 depending on how Column 1 relates to row 1
550 22
580 21
650 20
623 28
850 14
So my goal is using the second set of data.
at 550, 22 would be multiplied by 1,
at 650, 20 would be multiplied by 1.5
at 850, 14 would be multiplied by 5
I tried search for awhile on the community and through the "basics"
I might be wording this wrong by calling it indexing. I am trying to use a seperate array as an index and a variable.
E.g.
Row 1 I want to use as index, or lookup.
Row 2 are data
550 750 950
1 2 8
Column 1 would be reference from row 1
Column 2 would be multiplied against row 2 depending on how Column 1 relates to row 1
550 22
580 21
650 20
623 28
850 14
So my goal is using the second set of data.
at 550, 22 would be multiplied by 1,
at 650, 20 would be multiplied by 1.5
at 850, 14 would be multiplied by 5
I tried search for awhile on the community and through the "basics"
I might be wording this wrong by calling it indexing. basics, interpolation, indexing MATLAB Answers — New Questions
Trying to sign out of MATLAB desktop
I am trying to sign out of my MATLAB account on the desktop app, yet it is not letting me.
I keep getting this message, although I have nothing open aside from MATLAB and no scripts are running: Before signing out you must:
Close all MATLAB sessions, including the current one.Note: Restarting MATLAB requires internet access.I am trying to sign out of my MATLAB account on the desktop app, yet it is not letting me.
I keep getting this message, although I have nothing open aside from MATLAB and no scripts are running: Before signing out you must:
Close all MATLAB sessions, including the current one.Note: Restarting MATLAB requires internet access. I am trying to sign out of my MATLAB account on the desktop app, yet it is not letting me.
I keep getting this message, although I have nothing open aside from MATLAB and no scripts are running: Before signing out you must:
Close all MATLAB sessions, including the current one.Note: Restarting MATLAB requires internet access. matlab MATLAB Answers — New Questions
Detecting circles in an image to measure inner and outer diameter
Any reason why this code won’t detect the inner and outer diamter of the tube seen in the image below?
a = imread(‘E1-E2.jpg’);
imshow(a);
% Center and radius
[centers,radii] = imfindcircles(a,[20 1000],’ObjectPolarity’,’bright’, ‘Sensitivity’,0.95);
diameter = radii*2;
viscircles(centers, radii,’Color’,’b’);Any reason why this code won’t detect the inner and outer diamter of the tube seen in the image below?
a = imread(‘E1-E2.jpg’);
imshow(a);
% Center and radius
[centers,radii] = imfindcircles(a,[20 1000],’ObjectPolarity’,’bright’, ‘Sensitivity’,0.95);
diameter = radii*2;
viscircles(centers, radii,’Color’,’b’); Any reason why this code won’t detect the inner and outer diamter of the tube seen in the image below?
a = imread(‘E1-E2.jpg’);
imshow(a);
% Center and radius
[centers,radii] = imfindcircles(a,[20 1000],’ObjectPolarity’,’bright’, ‘Sensitivity’,0.95);
diameter = radii*2;
viscircles(centers, radii,’Color’,’b’); image, circle, wrong lens, image analysis MATLAB Answers — New Questions
Reading data from Microsoft Excel
What is the syntax for reading data from Microsoft Excel sheets? I tried the following and it returned error messages.
A = xlsread(‘amat.xlsx’,’sheet1′,’a1:a10′)
I even changed the case of S in sheet to capital and the error persisted. Anyone with an idea?What is the syntax for reading data from Microsoft Excel sheets? I tried the following and it returned error messages.
A = xlsread(‘amat.xlsx’,’sheet1′,’a1:a10′)
I even changed the case of S in sheet to capital and the error persisted. Anyone with an idea? What is the syntax for reading data from Microsoft Excel sheets? I tried the following and it returned error messages.
A = xlsread(‘amat.xlsx’,’sheet1′,’a1:a10′)
I even changed the case of S in sheet to capital and the error persisted. Anyone with an idea? transferred MATLAB Answers — New Questions