Tag Archives: matlab
Problem with MPC Control
This is my first time using the MPC control system. I designed the ANN-MPC control system in Simulink, but there was an issue with it. Can anyone guide me through the process? Thank you in advance.This is my first time using the MPC control system. I designed the ANN-MPC control system in Simulink, but there was an issue with it. Can anyone guide me through the process? Thank you in advance. This is my first time using the MPC control system. I designed the ANN-MPC control system in Simulink, but there was an issue with it. Can anyone guide me through the process? Thank you in advance. simulink, mpc MATLAB Answers — New Questions
How to use parallel background computing for triggering a oscilloscope measurement device (VISA API, IVI-C) from a matlab GUI? (error “Cannot parse adapters.config file”)
I want to trigger and collect data of my Tektronix DPO2004B Oscilloscope (Connected via USB and VISA API using a IVI-C Driver) from a Matlab GUI/App. For communication with the Oscilloscope I use the Quick-Control Oscilloscope instrument functionality (https://de.mathworks.com/help/instrument/oscilloscope.html)
If i use the function getDataFromOszilloscope() (see code below) it works fine, but the whole process of data collection takes about 7 seconds. When i call this function from a Matlab app, the execution will be blocked for a long time and other tasks can’t be handled during this time. Therefore i want to call this function in a parallel background pool. When i use f = parfeval(backgroundPool, @getDataFromOszilloscope,1); the following error occurs during the connection process inside oscilloscope().
Errormessage: Identifier "instrument:oscilloscope:failedToParseConfigFile"; "Cannot parse adapters.config file".
I guess the problem could be, that the backgroundPool uses all my Workers (6x) on the machine and this doesn’t work for this kind of device object, but i have no experience with parallel computing and scheduling. The function can be called when i use the parfeval(@getDataFromOszilloscope,1) without a backgroundPool and one Worker, but it still blocks the rest of my functionality because its not fully separated. I made a solution with the batch() function but it takes a lot of time to start the parallel pool every time i trigger the data acquisition.
Is there any way to get data from this oscilloscope without blocking the execution of other code inside the GUI?
%% Get data from Oszilloscope
p = backgroundPool; %Create backgroundPool
counter = 1;
numOfMeasurements = 4;
f(1:numOfMeasurements) = parallel.FevalFuture; %preallocate Future Object
%% Read specified number of measurements
while true
%Exit while loop if all measurements are collected in Background
if sum(ismember({f.State},’finished’)) == numOfMeasurements
out = fetchOutputs(f); %get data from background execution (Matlab throws error here but Problem occurs during parfeval)
break;
end
%Call Oszi at first iteration and after finishing calculation in background
if counter == 1 || strcmp(f(counter-1).State,’finished’)
disp(‘Calling getData’)
%Trigger oscilloscope for data collection in background
f(counter) = parfeval(p, @getDataFromOszilloscope,1); %Error
counter = counter+1;
end
disp(f(counter-1).State) %Output to check status of background calculation
% OTHER CODE FOR FURTHER EXECUTION IN APP WILL FOLLOW HERE
end
disp(‘END’)
%% Function for connecting to oscilloscope via installed IVI instrument driver (Uses VISA API)
% Error occurs during connection with the Oscilloscope
function data = getDataFromOszilloscope()
pause(0.1)
VisaAddress = ‘USB0::0x0699::0x039B::C020206::0::INSTR’;
IVI_Driver = ‘Tkdpo2k3k4k’;
myScope = oscilloscope(VisaAddress,IVI_Driver); %THE ERROR OCCURS HERE WHEN EXECUTED IN BACKGROUND!
data = readWaveform(myScope,’acquisition’, true); %Get Data from Oscilloscope
end
Further information:
Hardware + Driver:
Oscilloscope Tektronix DPO2004B
– IVI-C Driver Tkdpo2k3k4k v1.5 https://www.tek.com/en/support/software/driver/dpo2000-mso2000-dpo3000-and-dpo4000-mso3000-and-mso4000-mdo3000-and
Used Software:
Matlab R2023b
Matlab Instrument Toolbox
Instrument Control Toolbox Support Package for National Instruments VISA and ICP Interfaces https://de.mathworks.com/help/instrument/install-the-national-instruments-visa-and-icp-interfaces-support-package.html
NI-VISA software packages (installed with the VISA instrument control toolbox).I want to trigger and collect data of my Tektronix DPO2004B Oscilloscope (Connected via USB and VISA API using a IVI-C Driver) from a Matlab GUI/App. For communication with the Oscilloscope I use the Quick-Control Oscilloscope instrument functionality (https://de.mathworks.com/help/instrument/oscilloscope.html)
If i use the function getDataFromOszilloscope() (see code below) it works fine, but the whole process of data collection takes about 7 seconds. When i call this function from a Matlab app, the execution will be blocked for a long time and other tasks can’t be handled during this time. Therefore i want to call this function in a parallel background pool. When i use f = parfeval(backgroundPool, @getDataFromOszilloscope,1); the following error occurs during the connection process inside oscilloscope().
Errormessage: Identifier "instrument:oscilloscope:failedToParseConfigFile"; "Cannot parse adapters.config file".
I guess the problem could be, that the backgroundPool uses all my Workers (6x) on the machine and this doesn’t work for this kind of device object, but i have no experience with parallel computing and scheduling. The function can be called when i use the parfeval(@getDataFromOszilloscope,1) without a backgroundPool and one Worker, but it still blocks the rest of my functionality because its not fully separated. I made a solution with the batch() function but it takes a lot of time to start the parallel pool every time i trigger the data acquisition.
Is there any way to get data from this oscilloscope without blocking the execution of other code inside the GUI?
%% Get data from Oszilloscope
p = backgroundPool; %Create backgroundPool
counter = 1;
numOfMeasurements = 4;
f(1:numOfMeasurements) = parallel.FevalFuture; %preallocate Future Object
%% Read specified number of measurements
while true
%Exit while loop if all measurements are collected in Background
if sum(ismember({f.State},’finished’)) == numOfMeasurements
out = fetchOutputs(f); %get data from background execution (Matlab throws error here but Problem occurs during parfeval)
break;
end
%Call Oszi at first iteration and after finishing calculation in background
if counter == 1 || strcmp(f(counter-1).State,’finished’)
disp(‘Calling getData’)
%Trigger oscilloscope for data collection in background
f(counter) = parfeval(p, @getDataFromOszilloscope,1); %Error
counter = counter+1;
end
disp(f(counter-1).State) %Output to check status of background calculation
% OTHER CODE FOR FURTHER EXECUTION IN APP WILL FOLLOW HERE
end
disp(‘END’)
%% Function for connecting to oscilloscope via installed IVI instrument driver (Uses VISA API)
% Error occurs during connection with the Oscilloscope
function data = getDataFromOszilloscope()
pause(0.1)
VisaAddress = ‘USB0::0x0699::0x039B::C020206::0::INSTR’;
IVI_Driver = ‘Tkdpo2k3k4k’;
myScope = oscilloscope(VisaAddress,IVI_Driver); %THE ERROR OCCURS HERE WHEN EXECUTED IN BACKGROUND!
data = readWaveform(myScope,’acquisition’, true); %Get Data from Oscilloscope
end
Further information:
Hardware + Driver:
Oscilloscope Tektronix DPO2004B
– IVI-C Driver Tkdpo2k3k4k v1.5 https://www.tek.com/en/support/software/driver/dpo2000-mso2000-dpo3000-and-dpo4000-mso3000-and-mso4000-mdo3000-and
Used Software:
Matlab R2023b
Matlab Instrument Toolbox
Instrument Control Toolbox Support Package for National Instruments VISA and ICP Interfaces https://de.mathworks.com/help/instrument/install-the-national-instruments-visa-and-icp-interfaces-support-package.html
NI-VISA software packages (installed with the VISA instrument control toolbox). I want to trigger and collect data of my Tektronix DPO2004B Oscilloscope (Connected via USB and VISA API using a IVI-C Driver) from a Matlab GUI/App. For communication with the Oscilloscope I use the Quick-Control Oscilloscope instrument functionality (https://de.mathworks.com/help/instrument/oscilloscope.html)
If i use the function getDataFromOszilloscope() (see code below) it works fine, but the whole process of data collection takes about 7 seconds. When i call this function from a Matlab app, the execution will be blocked for a long time and other tasks can’t be handled during this time. Therefore i want to call this function in a parallel background pool. When i use f = parfeval(backgroundPool, @getDataFromOszilloscope,1); the following error occurs during the connection process inside oscilloscope().
Errormessage: Identifier "instrument:oscilloscope:failedToParseConfigFile"; "Cannot parse adapters.config file".
I guess the problem could be, that the backgroundPool uses all my Workers (6x) on the machine and this doesn’t work for this kind of device object, but i have no experience with parallel computing and scheduling. The function can be called when i use the parfeval(@getDataFromOszilloscope,1) without a backgroundPool and one Worker, but it still blocks the rest of my functionality because its not fully separated. I made a solution with the batch() function but it takes a lot of time to start the parallel pool every time i trigger the data acquisition.
Is there any way to get data from this oscilloscope without blocking the execution of other code inside the GUI?
%% Get data from Oszilloscope
p = backgroundPool; %Create backgroundPool
counter = 1;
numOfMeasurements = 4;
f(1:numOfMeasurements) = parallel.FevalFuture; %preallocate Future Object
%% Read specified number of measurements
while true
%Exit while loop if all measurements are collected in Background
if sum(ismember({f.State},’finished’)) == numOfMeasurements
out = fetchOutputs(f); %get data from background execution (Matlab throws error here but Problem occurs during parfeval)
break;
end
%Call Oszi at first iteration and after finishing calculation in background
if counter == 1 || strcmp(f(counter-1).State,’finished’)
disp(‘Calling getData’)
%Trigger oscilloscope for data collection in background
f(counter) = parfeval(p, @getDataFromOszilloscope,1); %Error
counter = counter+1;
end
disp(f(counter-1).State) %Output to check status of background calculation
% OTHER CODE FOR FURTHER EXECUTION IN APP WILL FOLLOW HERE
end
disp(‘END’)
%% Function for connecting to oscilloscope via installed IVI instrument driver (Uses VISA API)
% Error occurs during connection with the Oscilloscope
function data = getDataFromOszilloscope()
pause(0.1)
VisaAddress = ‘USB0::0x0699::0x039B::C020206::0::INSTR’;
IVI_Driver = ‘Tkdpo2k3k4k’;
myScope = oscilloscope(VisaAddress,IVI_Driver); %THE ERROR OCCURS HERE WHEN EXECUTED IN BACKGROUND!
data = readWaveform(myScope,’acquisition’, true); %Get Data from Oscilloscope
end
Further information:
Hardware + Driver:
Oscilloscope Tektronix DPO2004B
– IVI-C Driver Tkdpo2k3k4k v1.5 https://www.tek.com/en/support/software/driver/dpo2000-mso2000-dpo3000-and-dpo4000-mso3000-and-mso4000-mdo3000-and
Used Software:
Matlab R2023b
Matlab Instrument Toolbox
Instrument Control Toolbox Support Package for National Instruments VISA and ICP Interfaces https://de.mathworks.com/help/instrument/install-the-national-instruments-visa-and-icp-interfaces-support-package.html
NI-VISA software packages (installed with the VISA instrument control toolbox). parallel computing, background computing, ivi-c, tektronix, oscilloscope, visa, bocked execution MATLAB Answers — New Questions
Van der pol equation
Given the Van der pol equation
+ 𝝁 ( – 1) x + kx =0
Where 𝝁 = k = -1
Obtain the non-linear stage space representation of the system
Find the Jacobian matrix at the equilibrium point
Use the Lyaponov direct method to check for the stability of the system
(Hint V(x)= Px : PA + P = -1)Given the Van der pol equation
+ 𝝁 ( – 1) x + kx =0
Where 𝝁 = k = -1
Obtain the non-linear stage space representation of the system
Find the Jacobian matrix at the equilibrium point
Use the Lyaponov direct method to check for the stability of the system
(Hint V(x)= Px : PA + P = -1) Given the Van der pol equation
+ 𝝁 ( – 1) x + kx =0
Where 𝝁 = k = -1
Obtain the non-linear stage space representation of the system
Find the Jacobian matrix at the equilibrium point
Use the Lyaponov direct method to check for the stability of the system
(Hint V(x)= Px : PA + P = -1) control theory ii MATLAB Answers — New Questions
How to make a open switch fault using ePWM block(Texas instruments c2000)??
I’m trying to make open switch fault situation (or the duty cycle of the high side switch to be 0 while not effects the low side one.) . And I’m using a EPWM block from texas instruments c2000 add-on.
I want a high side switch to be opened not the low side one too.
I did
1) continuous software force to control the high side switch(ePWM-A)….. but it’s the highest priority signal that makes ePWM-B signal changed.
Is there any way I could solve this problem??I’m trying to make open switch fault situation (or the duty cycle of the high side switch to be 0 while not effects the low side one.) . And I’m using a EPWM block from texas instruments c2000 add-on.
I want a high side switch to be opened not the low side one too.
I did
1) continuous software force to control the high side switch(ePWM-A)….. but it’s the highest priority signal that makes ePWM-B signal changed.
Is there any way I could solve this problem?? I’m trying to make open switch fault situation (or the duty cycle of the high side switch to be 0 while not effects the low side one.) . And I’m using a EPWM block from texas instruments c2000 add-on.
I want a high side switch to be opened not the low side one too.
I did
1) continuous software force to control the high side switch(ePWM-A)….. but it’s the highest priority signal that makes ePWM-B signal changed.
Is there any way I could solve this problem?? epwm, open switch fault MATLAB Answers — New Questions
How to Debug Python Script (using breakpoints) that is called from Matlab on MAC OS
I am using MATLAB_R2023b.
I have wrote a Python script which is called from Matlab files. I want to debug the Python script. I have tried logging information using print statements in Python but that is not the preferred way to debug as I have to do a lot of work. I wanted to know if there are any work arounds like using visual studio code or other IDE for the same.
I am using MACOS, now that Visual Studio is retiring for MACOS how should one go about debugging it?I am using MATLAB_R2023b.
I have wrote a Python script which is called from Matlab files. I want to debug the Python script. I have tried logging information using print statements in Python but that is not the preferred way to debug as I have to do a lot of work. I wanted to know if there are any work arounds like using visual studio code or other IDE for the same.
I am using MACOS, now that Visual Studio is retiring for MACOS how should one go about debugging it? I am using MATLAB_R2023b.
I have wrote a Python script which is called from Matlab files. I want to debug the Python script. I have tried logging information using print statements in Python but that is not the preferred way to debug as I have to do a lot of work. I wanted to know if there are any work arounds like using visual studio code or other IDE for the same.
I am using MACOS, now that Visual Studio is retiring for MACOS how should one go about debugging it? matlab, python, debugger MATLAB Answers — New Questions
How to extract the values of kml file x,y,z from MATLAB
Is it possible to extract the values of kml file x,y,z from matlab?
Is there any url or document to refer to in this regard?Is it possible to extract the values of kml file x,y,z from matlab?
Is there any url or document to refer to in this regard? Is it possible to extract the values of kml file x,y,z from matlab?
Is there any url or document to refer to in this regard? kml MATLAB Answers — New Questions
How to turn off epwm using software force logic in c2000 f28388d?
Hi,
I am using an F28388D to control a 3-phase full bridge inverter. I am utilizing a code with a state diagram for this purpose. I have a requirement to completely turn off the third leg of the inverter at one point for a few seconds based on inputs from Stateflow. I tried using the software force logic, but I am unable to turn off the switches. The attached diagram shows the settings I have tried for this. I provided an input of 1 to the SW input port whenever I needed to turn off the leg, but it’s not working, and I am unable to find any resources on how to implement this.
Is there anyone who can help with this?
Thanks in advance.
Regards,
KripaHi,
I am using an F28388D to control a 3-phase full bridge inverter. I am utilizing a code with a state diagram for this purpose. I have a requirement to completely turn off the third leg of the inverter at one point for a few seconds based on inputs from Stateflow. I tried using the software force logic, but I am unable to turn off the switches. The attached diagram shows the settings I have tried for this. I provided an input of 1 to the SW input port whenever I needed to turn off the leg, but it’s not working, and I am unable to find any resources on how to implement this.
Is there anyone who can help with this?
Thanks in advance.
Regards,
Kripa Hi,
I am using an F28388D to control a 3-phase full bridge inverter. I am utilizing a code with a state diagram for this purpose. I have a requirement to completely turn off the third leg of the inverter at one point for a few seconds based on inputs from Stateflow. I tried using the software force logic, but I am unable to turn off the switches. The attached diagram shows the settings I have tried for this. I provided an input of 1 to the SW input port whenever I needed to turn off the leg, but it’s not working, and I am unable to find any resources on how to implement this.
Is there anyone who can help with this?
Thanks in advance.
Regards,
Kripa c2000, f28388d, epwm MATLAB Answers — New Questions
Different Algos giving highest FS accuracy for diff datasets which are based on same category of disorder.
HI,
I have used your code and picked 10 SI algos to find FS accuracy on 4 different datasets(all our textual categorical datasets with binary output, having different number of attributes)
Now my issue is the for each dataset different algorithm is giving highest accuracy. I want that same algorithm should give highest accuracy for all 4 datasets . Please help
Thanks
Preeti
monga.kamra@gmail.comHI,
I have used your code and picked 10 SI algos to find FS accuracy on 4 different datasets(all our textual categorical datasets with binary output, having different number of attributes)
Now my issue is the for each dataset different algorithm is giving highest accuracy. I want that same algorithm should give highest accuracy for all 4 datasets . Please help
Thanks
Preeti
monga.kamra@gmail.com HI,
I have used your code and picked 10 SI algos to find FS accuracy on 4 different datasets(all our textual categorical datasets with binary output, having different number of attributes)
Now my issue is the for each dataset different algorithm is giving highest accuracy. I want that same algorithm should give highest accuracy for all 4 datasets . Please help
Thanks
Preeti
monga.kamra@gmail.com matlab, machine learning, feature selection MATLAB Answers — New Questions
How to mix gases with different properties in Simulink ?
Hello everyone,
I work on a project where I have to use three different gases for mix them :
I use simulink for obtain the density of the gas mixed but I have this error message :
"Error compiling Simscape network for model labo.
Caused by: [‘labo/Gas Properties (G)1’, ‘labo/Gas Properties (G)’]: Failed to propagate domain parameters. Domain parameters are propagated to the same set of nodes from sources: ‘Subsystem10.Gas_Properties_G1.A’ and ‘Subsystem10.Gas_Properties_G.A’. Each node may only have at most one source of propagation."
So, how can I mix different gases if I can’t define a physical constant for each of them ?
As a reminder, I don’t know gas properties for the mixed gas.
Thanks for your helpHello everyone,
I work on a project where I have to use three different gases for mix them :
I use simulink for obtain the density of the gas mixed but I have this error message :
"Error compiling Simscape network for model labo.
Caused by: [‘labo/Gas Properties (G)1’, ‘labo/Gas Properties (G)’]: Failed to propagate domain parameters. Domain parameters are propagated to the same set of nodes from sources: ‘Subsystem10.Gas_Properties_G1.A’ and ‘Subsystem10.Gas_Properties_G.A’. Each node may only have at most one source of propagation."
So, how can I mix different gases if I can’t define a physical constant for each of them ?
As a reminder, I don’t know gas properties for the mixed gas.
Thanks for your help Hello everyone,
I work on a project where I have to use three different gases for mix them :
I use simulink for obtain the density of the gas mixed but I have this error message :
"Error compiling Simscape network for model labo.
Caused by: [‘labo/Gas Properties (G)1’, ‘labo/Gas Properties (G)’]: Failed to propagate domain parameters. Domain parameters are propagated to the same set of nodes from sources: ‘Subsystem10.Gas_Properties_G1.A’ and ‘Subsystem10.Gas_Properties_G.A’. Each node may only have at most one source of propagation."
So, how can I mix different gases if I can’t define a physical constant for each of them ?
As a reminder, I don’t know gas properties for the mixed gas.
Thanks for your help gas-mix MATLAB Answers — New Questions
Create a table that contains text and figures using the reporting toolbox
Hi! I am using your reporting function but I have had struggles building a scheme 2 by 2 where positions 1 and 4 are figures, and positions 2 and 3 text.
I have this code:
tp = TitlePage();
tit = Paragraph("Presentación del Primer Trimestre de 2024:");
tit.Style = {HAlign("left"),FontFamily("sans-serif"),…
FontSize("45pt"),Color("white"),…
BackgroundColor("#0072BD"),…
OuterMargin("0in","0in",".5in","1in"),…
HAlign("center")};
tp.Title = tit;
add(rpt, tp);
%% my code to create figures – plots
var_name = [‘fig’, num2str(j),’Img’];
eval([var_name, ‘ = Image(getSnapshotImage(Figure(fig), rpt));’]);
% Close the figure to avoid accumulation
close(fig);
end
% % % % % % % % ================================ PAGE 1 ===============================
br = PageBreak();
intro1 = HTML([‘<p style="white-space:pre; font-size: 25px; font-family: sans-serif;">’, …
‘SOMETHING.</p>’,…
]);
append(rpt, intro1)
lo_table1 = Table({
fig1Img, fig2Img; …
fig3Img, []});
lo_table1.entry(1,1).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table1.entry(1,2).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table1.entry(2,1).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table1.entry(2,2).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table1.Style = {Width(‘100%’), ResizeToFitContents(true)};
add(rpt, lo_table1);
% % % % % % % % ================================ PAGE 2 ===============================
% Define the HTML content for the text cells
PAR1 = HTML([‘<p style="white-space:pre; font-size: 25px; font-family: sans-serif;">’, …
‘SOMETHING.</p>’,…
]);
PAR2 = HTML([‘<p style="white-space:pre; font-size: 25px; font-family: sans-serif;">’, …
‘SOMETHING.</p>’,…
]);
lo_table2 = Table({ fig4Img, PAR1);…
PAR2, fig5Img});
lo_table2.entry(1,1).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table2.entry(1,2).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table2.entry(2,1).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table2.entry(2,2).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table2.Style = {Width(‘100%’), ResizeToFitContents(true)};
add(rpt, lo_table2);
br2 = PageBreak();
append(rpt,br2)
close(rpt);
rptview(rpt);
My problem is that the figures appears in my PDF report. But the text does not.
How can I solve it?
Thanks in advance.Hi! I am using your reporting function but I have had struggles building a scheme 2 by 2 where positions 1 and 4 are figures, and positions 2 and 3 text.
I have this code:
tp = TitlePage();
tit = Paragraph("Presentación del Primer Trimestre de 2024:");
tit.Style = {HAlign("left"),FontFamily("sans-serif"),…
FontSize("45pt"),Color("white"),…
BackgroundColor("#0072BD"),…
OuterMargin("0in","0in",".5in","1in"),…
HAlign("center")};
tp.Title = tit;
add(rpt, tp);
%% my code to create figures – plots
var_name = [‘fig’, num2str(j),’Img’];
eval([var_name, ‘ = Image(getSnapshotImage(Figure(fig), rpt));’]);
% Close the figure to avoid accumulation
close(fig);
end
% % % % % % % % ================================ PAGE 1 ===============================
br = PageBreak();
intro1 = HTML([‘<p style="white-space:pre; font-size: 25px; font-family: sans-serif;">’, …
‘SOMETHING.</p>’,…
]);
append(rpt, intro1)
lo_table1 = Table({
fig1Img, fig2Img; …
fig3Img, []});
lo_table1.entry(1,1).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table1.entry(1,2).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table1.entry(2,1).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table1.entry(2,2).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table1.Style = {Width(‘100%’), ResizeToFitContents(true)};
add(rpt, lo_table1);
% % % % % % % % ================================ PAGE 2 ===============================
% Define the HTML content for the text cells
PAR1 = HTML([‘<p style="white-space:pre; font-size: 25px; font-family: sans-serif;">’, …
‘SOMETHING.</p>’,…
]);
PAR2 = HTML([‘<p style="white-space:pre; font-size: 25px; font-family: sans-serif;">’, …
‘SOMETHING.</p>’,…
]);
lo_table2 = Table({ fig4Img, PAR1);…
PAR2, fig5Img});
lo_table2.entry(1,1).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table2.entry(1,2).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table2.entry(2,1).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table2.entry(2,2).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table2.Style = {Width(‘100%’), ResizeToFitContents(true)};
add(rpt, lo_table2);
br2 = PageBreak();
append(rpt,br2)
close(rpt);
rptview(rpt);
My problem is that the figures appears in my PDF report. But the text does not.
How can I solve it?
Thanks in advance. Hi! I am using your reporting function but I have had struggles building a scheme 2 by 2 where positions 1 and 4 are figures, and positions 2 and 3 text.
I have this code:
tp = TitlePage();
tit = Paragraph("Presentación del Primer Trimestre de 2024:");
tit.Style = {HAlign("left"),FontFamily("sans-serif"),…
FontSize("45pt"),Color("white"),…
BackgroundColor("#0072BD"),…
OuterMargin("0in","0in",".5in","1in"),…
HAlign("center")};
tp.Title = tit;
add(rpt, tp);
%% my code to create figures – plots
var_name = [‘fig’, num2str(j),’Img’];
eval([var_name, ‘ = Image(getSnapshotImage(Figure(fig), rpt));’]);
% Close the figure to avoid accumulation
close(fig);
end
% % % % % % % % ================================ PAGE 1 ===============================
br = PageBreak();
intro1 = HTML([‘<p style="white-space:pre; font-size: 25px; font-family: sans-serif;">’, …
‘SOMETHING.</p>’,…
]);
append(rpt, intro1)
lo_table1 = Table({
fig1Img, fig2Img; …
fig3Img, []});
lo_table1.entry(1,1).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table1.entry(1,2).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table1.entry(2,1).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table1.entry(2,2).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table1.Style = {Width(‘100%’), ResizeToFitContents(true)};
add(rpt, lo_table1);
% % % % % % % % ================================ PAGE 2 ===============================
% Define the HTML content for the text cells
PAR1 = HTML([‘<p style="white-space:pre; font-size: 25px; font-family: sans-serif;">’, …
‘SOMETHING.</p>’,…
]);
PAR2 = HTML([‘<p style="white-space:pre; font-size: 25px; font-family: sans-serif;">’, …
‘SOMETHING.</p>’,…
]);
lo_table2 = Table({ fig4Img, PAR1);…
PAR2, fig5Img});
lo_table2.entry(1,1).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table2.entry(1,2).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table2.entry(2,1).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table2.entry(2,2).Style = {Width(‘8in’), Height(‘3.8in’)};
lo_table2.Style = {Width(‘100%’), ResizeToFitContents(true)};
add(rpt, lo_table2);
br2 = PageBreak();
append(rpt,br2)
close(rpt);
rptview(rpt);
My problem is that the figures appears in my PDF report. But the text does not.
How can I solve it?
Thanks in advance. #reports MATLAB Answers — New Questions
Do I need to scale the data before using matlab pca function
I am using MATLAB pca toolbox. I am wondering if I need to scale the data before I use it. I found that it centers the data around the mean in PCA toolbox.I am using MATLAB pca toolbox. I am wondering if I need to scale the data before I use it. I found that it centers the data around the mean in PCA toolbox. I am using MATLAB pca toolbox. I am wondering if I need to scale the data before I use it. I found that it centers the data around the mean in PCA toolbox. pca MATLAB Answers — New Questions
design(fdesign.lowpass()) vs dsp.Filter(firpm())
Hello,
I am trying to design a very strict LPF. Some of the design parameters are Fs 1000Hz and Fpass 0.5Hz and Fstop 1Hz with 0.01 passband ripple and 110 db stopband attenuation.
When I try to design this filter with the FDAtool, the tool takes some time but designs a ~10k tap FIR filter. If I select to generate MATLAB code for this design, the code is generated using firpm().
When I try to use the fdesign.lowpass() with the same specification and then with design( ‘equiripple’) the method does not converge (I let the design run for some time and no output is given).
My question is, what is the difference between these two methods and why cant I design the specified filter with the fdesign.lowpass ?Hello,
I am trying to design a very strict LPF. Some of the design parameters are Fs 1000Hz and Fpass 0.5Hz and Fstop 1Hz with 0.01 passband ripple and 110 db stopband attenuation.
When I try to design this filter with the FDAtool, the tool takes some time but designs a ~10k tap FIR filter. If I select to generate MATLAB code for this design, the code is generated using firpm().
When I try to use the fdesign.lowpass() with the same specification and then with design( ‘equiripple’) the method does not converge (I let the design run for some time and no output is given).
My question is, what is the difference between these two methods and why cant I design the specified filter with the fdesign.lowpass ? Hello,
I am trying to design a very strict LPF. Some of the design parameters are Fs 1000Hz and Fpass 0.5Hz and Fstop 1Hz with 0.01 passband ripple and 110 db stopband attenuation.
When I try to design this filter with the FDAtool, the tool takes some time but designs a ~10k tap FIR filter. If I select to generate MATLAB code for this design, the code is generated using firpm().
When I try to use the fdesign.lowpass() with the same specification and then with design( ‘equiripple’) the method does not converge (I let the design run for some time and no output is given).
My question is, what is the difference between these two methods and why cant I design the specified filter with the fdesign.lowpass ? filter design MATLAB Answers — New Questions
Recursive backtracking with cell arrays?
I’m working on a function to recursively generate solutions to a given sudoku puzzle represented by a 9×9 array with NaN representing blank spaces utilizing backtracking.
function cellSolutions = solveSudoku(PuzzleA)
cellSolutions = {};
if ~reject(PuzzleA)
if accept(PuzzleA)
disp(‘solution found’)
cellSolutions{end+1} = PuzzleA;
end
[nP, Idx] = firstChild(PuzzleA);
while (~isempty(nP))
possibleSolution = solveSudoku(nP);
if (~isempty(possibleSolution))
cellSolutions{end+1} = possibleSolution{1};
end
nP = nextChild(nP,Idx);
end
end
end
The return cellSolutions is a cell array that contains 0, 1, or more solutions depending on how many exist. The trouble I’m having is actually getting the solutions that are found to appear in the cellSolution returned with the initial call. What I’m hoping for is:
cellSolutions
{[9×9 double] [9×9 double]} or {} or {[9×9 double]}
I can indeed confirm that one or more solutions are found with the disp call, but I’m not sure how to manipulate the cell array. I’m pretty sure the problem lies with:
while (~isempty(nP))
possibleSolution = solveSudoku(nP);
if (~isempty(possibleSolution))
cellSolutions{end+1} = possibleSolution{1};
end
nP = nextChild(nP,Idx);
end
Some other info: reject determines whether the current puzzle satisfies the rules of sudoku; accept checks additionally that there are no empty spaces; firstChild finds and instance of NaN in a given sudoku puzzle, and changes it to 1 and returns linear index it changed and the new puzzle; nextChild takes a sudoku puzzle and index, if the value at that index is not 9, then it increments the value and returns the new puzzle. Thanks!I’m working on a function to recursively generate solutions to a given sudoku puzzle represented by a 9×9 array with NaN representing blank spaces utilizing backtracking.
function cellSolutions = solveSudoku(PuzzleA)
cellSolutions = {};
if ~reject(PuzzleA)
if accept(PuzzleA)
disp(‘solution found’)
cellSolutions{end+1} = PuzzleA;
end
[nP, Idx] = firstChild(PuzzleA);
while (~isempty(nP))
possibleSolution = solveSudoku(nP);
if (~isempty(possibleSolution))
cellSolutions{end+1} = possibleSolution{1};
end
nP = nextChild(nP,Idx);
end
end
end
The return cellSolutions is a cell array that contains 0, 1, or more solutions depending on how many exist. The trouble I’m having is actually getting the solutions that are found to appear in the cellSolution returned with the initial call. What I’m hoping for is:
cellSolutions
{[9×9 double] [9×9 double]} or {} or {[9×9 double]}
I can indeed confirm that one or more solutions are found with the disp call, but I’m not sure how to manipulate the cell array. I’m pretty sure the problem lies with:
while (~isempty(nP))
possibleSolution = solveSudoku(nP);
if (~isempty(possibleSolution))
cellSolutions{end+1} = possibleSolution{1};
end
nP = nextChild(nP,Idx);
end
Some other info: reject determines whether the current puzzle satisfies the rules of sudoku; accept checks additionally that there are no empty spaces; firstChild finds and instance of NaN in a given sudoku puzzle, and changes it to 1 and returns linear index it changed and the new puzzle; nextChild takes a sudoku puzzle and index, if the value at that index is not 9, then it increments the value and returns the new puzzle. Thanks! I’m working on a function to recursively generate solutions to a given sudoku puzzle represented by a 9×9 array with NaN representing blank spaces utilizing backtracking.
function cellSolutions = solveSudoku(PuzzleA)
cellSolutions = {};
if ~reject(PuzzleA)
if accept(PuzzleA)
disp(‘solution found’)
cellSolutions{end+1} = PuzzleA;
end
[nP, Idx] = firstChild(PuzzleA);
while (~isempty(nP))
possibleSolution = solveSudoku(nP);
if (~isempty(possibleSolution))
cellSolutions{end+1} = possibleSolution{1};
end
nP = nextChild(nP,Idx);
end
end
end
The return cellSolutions is a cell array that contains 0, 1, or more solutions depending on how many exist. The trouble I’m having is actually getting the solutions that are found to appear in the cellSolution returned with the initial call. What I’m hoping for is:
cellSolutions
{[9×9 double] [9×9 double]} or {} or {[9×9 double]}
I can indeed confirm that one or more solutions are found with the disp call, but I’m not sure how to manipulate the cell array. I’m pretty sure the problem lies with:
while (~isempty(nP))
possibleSolution = solveSudoku(nP);
if (~isempty(possibleSolution))
cellSolutions{end+1} = possibleSolution{1};
end
nP = nextChild(nP,Idx);
end
Some other info: reject determines whether the current puzzle satisfies the rules of sudoku; accept checks additionally that there are no empty spaces; firstChild finds and instance of NaN in a given sudoku puzzle, and changes it to 1 and returns linear index it changed and the new puzzle; nextChild takes a sudoku puzzle and index, if the value at that index is not 9, then it increments the value and returns the new puzzle. Thanks! recursion, sudoku, recursive backtracking, cell array MATLAB Answers — New Questions
Solution of a 2nd order non linear implicit differential equation using ode15i implicit solver
This is a nonlinear differential equation of 2nd order and implicit
I am providing the code I have tried but Iam not getting hoe the velocity changes with time at different time what is the value of velocity.
% Initial conditions
y0 = [0 2]; % initial displacement and velocity
yp0_guess = [0; 0]; % Initial guess for derivatives
% Time span
tspan = [0 20]; % time span for the solution
% Solve using ode15i
[t, y] = ode15i(@implicitODE, tspan, y0, yp0_guess);
% Plot the displacement over time
figure;
subplot(2,1,1);
plot(t, y(:,1));
xlabel(‘Time (s)’);
ylabel(‘Displacement (y)’);
title(‘Displacement vs Time’);
% Plot the velocity over time
subplot(2,1,2);
plot(t,y(:,2)); % y(:,2) corresponds to the velocity (dy/dt)
xlabel(‘Time (s)’);
ylabel(‘Velocity (dy/dt)’);
title(‘Velocity vs Time’);
function res = implicitODE(t, y, yp)
% Constants
pi = 3.141592653589793;
k1 = 4.4049e-18;
k2 = 0.1101;
a = 17.71e-3;
% Extract variables
y1 = y(1); % y1 corresponds to y(t)
y2 = y(2); % y2 corresponds to dy/dt
yp1 = yp(1); % yp1 corresponds to y2
yp2 = yp(2); % yp2 corresponds to y2′
% Compute the residuals
res = zeros(2,1);
res(1) = yp1 – y2; % y1′ = y2
res(2) = yp2 – (-k1 * y1^2 * y2 / (a^2 + y1^2)^2.5 / k2)-9.81; % y2′ equation
endThis is a nonlinear differential equation of 2nd order and implicit
I am providing the code I have tried but Iam not getting hoe the velocity changes with time at different time what is the value of velocity.
% Initial conditions
y0 = [0 2]; % initial displacement and velocity
yp0_guess = [0; 0]; % Initial guess for derivatives
% Time span
tspan = [0 20]; % time span for the solution
% Solve using ode15i
[t, y] = ode15i(@implicitODE, tspan, y0, yp0_guess);
% Plot the displacement over time
figure;
subplot(2,1,1);
plot(t, y(:,1));
xlabel(‘Time (s)’);
ylabel(‘Displacement (y)’);
title(‘Displacement vs Time’);
% Plot the velocity over time
subplot(2,1,2);
plot(t,y(:,2)); % y(:,2) corresponds to the velocity (dy/dt)
xlabel(‘Time (s)’);
ylabel(‘Velocity (dy/dt)’);
title(‘Velocity vs Time’);
function res = implicitODE(t, y, yp)
% Constants
pi = 3.141592653589793;
k1 = 4.4049e-18;
k2 = 0.1101;
a = 17.71e-3;
% Extract variables
y1 = y(1); % y1 corresponds to y(t)
y2 = y(2); % y2 corresponds to dy/dt
yp1 = yp(1); % yp1 corresponds to y2
yp2 = yp(2); % yp2 corresponds to y2′
% Compute the residuals
res = zeros(2,1);
res(1) = yp1 – y2; % y1′ = y2
res(2) = yp2 – (-k1 * y1^2 * y2 / (a^2 + y1^2)^2.5 / k2)-9.81; % y2′ equation
end This is a nonlinear differential equation of 2nd order and implicit
I am providing the code I have tried but Iam not getting hoe the velocity changes with time at different time what is the value of velocity.
% Initial conditions
y0 = [0 2]; % initial displacement and velocity
yp0_guess = [0; 0]; % Initial guess for derivatives
% Time span
tspan = [0 20]; % time span for the solution
% Solve using ode15i
[t, y] = ode15i(@implicitODE, tspan, y0, yp0_guess);
% Plot the displacement over time
figure;
subplot(2,1,1);
plot(t, y(:,1));
xlabel(‘Time (s)’);
ylabel(‘Displacement (y)’);
title(‘Displacement vs Time’);
% Plot the velocity over time
subplot(2,1,2);
plot(t,y(:,2)); % y(:,2) corresponds to the velocity (dy/dt)
xlabel(‘Time (s)’);
ylabel(‘Velocity (dy/dt)’);
title(‘Velocity vs Time’);
function res = implicitODE(t, y, yp)
% Constants
pi = 3.141592653589793;
k1 = 4.4049e-18;
k2 = 0.1101;
a = 17.71e-3;
% Extract variables
y1 = y(1); % y1 corresponds to y(t)
y2 = y(2); % y2 corresponds to dy/dt
yp1 = yp(1); % yp1 corresponds to y2
yp2 = yp(2); % yp2 corresponds to y2′
% Compute the residuals
res = zeros(2,1);
res(1) = yp1 – y2; % y1′ = y2
res(2) = yp2 – (-k1 * y1^2 * y2 / (a^2 + y1^2)^2.5 / k2)-9.81; % y2′ equation
end ode15i, 2nd order ode, nonlinear ode, implicit solution MATLAB Answers — New Questions
How can I load a tif file and save it again with the same parameters as before?
I want to load a tif file and save it again, but the saved file is not the same like the original file. helgoland_bathy.tif is a bathymetry map with georeferenced coordinates. The problem is that the second file has the wrong entries in the info parameter. Like PixelScale, RefMatrix and so on. It is possble to get all ifnormation from the tif file and save this again as a new tif with the identical information?
infilename = ‘helgoland_bathy.tif’;
[A,R] = readgeoraster(infilename);
info = geotiffinfo(infilename);
geoTags = info.GeoTIFFTags.GeoKeyDirectoryTag;
geotiffwrite(‘helgoland_bahty_2.tif’,A,R,’GeoKeyDirectoryTag’,geoTags)I want to load a tif file and save it again, but the saved file is not the same like the original file. helgoland_bathy.tif is a bathymetry map with georeferenced coordinates. The problem is that the second file has the wrong entries in the info parameter. Like PixelScale, RefMatrix and so on. It is possble to get all ifnormation from the tif file and save this again as a new tif with the identical information?
infilename = ‘helgoland_bathy.tif’;
[A,R] = readgeoraster(infilename);
info = geotiffinfo(infilename);
geoTags = info.GeoTIFFTags.GeoKeyDirectoryTag;
geotiffwrite(‘helgoland_bahty_2.tif’,A,R,’GeoKeyDirectoryTag’,geoTags) I want to load a tif file and save it again, but the saved file is not the same like the original file. helgoland_bathy.tif is a bathymetry map with georeferenced coordinates. The problem is that the second file has the wrong entries in the info parameter. Like PixelScale, RefMatrix and so on. It is possble to get all ifnormation from the tif file and save this again as a new tif with the identical information?
infilename = ‘helgoland_bathy.tif’;
[A,R] = readgeoraster(infilename);
info = geotiffinfo(infilename);
geoTags = info.GeoTIFFTags.GeoKeyDirectoryTag;
geotiffwrite(‘helgoland_bahty_2.tif’,A,R,’GeoKeyDirectoryTag’,geoTags) tif MATLAB Answers — New Questions
When did the syntax for linprog change
At one point, the input syntax for linprog was
x=linprog(f,A,b,Aeq,beq,lb,ub,x0,options)
but now (R2023b) I see that it has changed to,
x = linprog(f,A,b,Aeq,beq,lb,ub,options)
In what release was the support for the first syntax discontinued?At one point, the input syntax for linprog was
x=linprog(f,A,b,Aeq,beq,lb,ub,x0,options)
but now (R2023b) I see that it has changed to,
x = linprog(f,A,b,Aeq,beq,lb,ub,options)
In what release was the support for the first syntax discontinued? At one point, the input syntax for linprog was
x=linprog(f,A,b,Aeq,beq,lb,ub,x0,options)
but now (R2023b) I see that it has changed to,
x = linprog(f,A,b,Aeq,beq,lb,ub,options)
In what release was the support for the first syntax discontinued? linprog, syntax, release MATLAB Answers — New Questions
How to Connect Matlab with Stock Brokers in India
Indian Stock Brokers provides API link and Authorization code from their url. Based on it one gets logged in in their system. Procedures are available for connecting with Python but not with MATLAB. So requesting you to provide detailed steps by which it 8s possible to get connected with top brokers and access live market data.Indian Stock Brokers provides API link and Authorization code from their url. Based on it one gets logged in in their system. Procedures are available for connecting with Python but not with MATLAB. So requesting you to provide detailed steps by which it 8s possible to get connected with top brokers and access live market data. Indian Stock Brokers provides API link and Authorization code from their url. Based on it one gets logged in in their system. Procedures are available for connecting with Python but not with MATLAB. So requesting you to provide detailed steps by which it 8s possible to get connected with top brokers and access live market data. matlab, trading, trading toolbox, api MATLAB Answers — New Questions
marsbar ROI export error
I get this error when exporting ROI data on marsbar.
The file directory bewlow in fact, does not exist and is not associated with the process at all. I didn’t even intend to use that file.
Anybody has a clue of what’s going on and how to solve it?
[Error message]
Mapping files : Error using spm_vol>spm_vol_hdr
File "/Users/shchoi/Desktop/Lab/05_experiments/01_attentional_capture/MRIdata/03_1st_level/01_localizer/CON/CON12/con_0005.nii" does
not exist.
Error in spm_vol (line 61)
v = spm_vol_hdr(deblank(P(i,:)));
Error in mars_image_scaling (line 120)
VY = spm_vol(VY);
Error in marsbar (line 980)
[VY row] = mars_image_scaling(marsD);
Error in spm (line 1004)
evalin(‘base’,CB)
Error while evaluating UIControl Callback.I get this error when exporting ROI data on marsbar.
The file directory bewlow in fact, does not exist and is not associated with the process at all. I didn’t even intend to use that file.
Anybody has a clue of what’s going on and how to solve it?
[Error message]
Mapping files : Error using spm_vol>spm_vol_hdr
File "/Users/shchoi/Desktop/Lab/05_experiments/01_attentional_capture/MRIdata/03_1st_level/01_localizer/CON/CON12/con_0005.nii" does
not exist.
Error in spm_vol (line 61)
v = spm_vol_hdr(deblank(P(i,:)));
Error in mars_image_scaling (line 120)
VY = spm_vol(VY);
Error in marsbar (line 980)
[VY row] = mars_image_scaling(marsD);
Error in spm (line 1004)
evalin(‘base’,CB)
Error while evaluating UIControl Callback. I get this error when exporting ROI data on marsbar.
The file directory bewlow in fact, does not exist and is not associated with the process at all. I didn’t even intend to use that file.
Anybody has a clue of what’s going on and how to solve it?
[Error message]
Mapping files : Error using spm_vol>spm_vol_hdr
File "/Users/shchoi/Desktop/Lab/05_experiments/01_attentional_capture/MRIdata/03_1st_level/01_localizer/CON/CON12/con_0005.nii" does
not exist.
Error in spm_vol (line 61)
v = spm_vol_hdr(deblank(P(i,:)));
Error in mars_image_scaling (line 120)
VY = spm_vol(VY);
Error in marsbar (line 980)
[VY row] = mars_image_scaling(marsD);
Error in spm (line 1004)
evalin(‘base’,CB)
Error while evaluating UIControl Callback. marsbar, percent signal change, roi, spm12 MATLAB Answers — New Questions
How to output the application screen as an image or PDF on the web app
I am creating a web application.
After using the application on the web, I would like to save the application screen (UIFigure) as an image or PDF.
Do you have a good method?
I can use exportapp and imwrite on the app designer, but I can’t use it on the web.I am creating a web application.
After using the application on the web, I would like to save the application screen (UIFigure) as an image or PDF.
Do you have a good method?
I can use exportapp and imwrite on the app designer, but I can’t use it on the web. I am creating a web application.
After using the application on the web, I would like to save the application screen (UIFigure) as an image or PDF.
Do you have a good method?
I can use exportapp and imwrite on the app designer, but I can’t use it on the web. web, app designer, export, uifigure MATLAB Answers — New Questions
Dynamic script which creates and deletes parts over time
Dear all,
I wrote a function CoolingCalc that calculates the cooling of a porous material based on the input conditions. I want to simulate adding material into a tank at a certain rate per second (m_in). If CoolingCalc represents a "block" containing m_in material per second, then the total cooling at a given time should be the sum of the cooling from all blocks, considering that blocks were also added earlier.
Additionally, if I set a total mass Mass_setpoint after which I start removing material from the tank, I would need a script that adds CoolingCalc blocks until their combined mass reaches Mass_setpoint, and then begins removing the earliest blocks that were created.
My understanding is that this requires a dynamic script that creates and deletes these blocks over time.
Is it possible to implement this in MATLAB?
I am grateful for any help you can provide.
Best regards,
clear; clc
t_cycle = 200; % [s] simulation time
T = 303.15; % [K] temperature
P = 1; % [MPa] pressure
% Material related
m_in = 0.001; % [kg/s] inlet flowrate
Mass_setpoint = 0.1; % [kg] set point after which material is removed
m_out = 0.002; % [kg/s] outlet flowrate
Xs = 0.002; % [m^3/kg] Pore volume of material
Q_st = 450; % [kJ/kg] Isosteric heat of material
Xeq0 = 1; % Initial value of X
% Plot
[Q_cooling] = CoolingCalc(T, P, Q_st, Xs, Xeq0, m_in, t_cycle);
plot(Q_cooling)
hold onDear all,
I wrote a function CoolingCalc that calculates the cooling of a porous material based on the input conditions. I want to simulate adding material into a tank at a certain rate per second (m_in). If CoolingCalc represents a "block" containing m_in material per second, then the total cooling at a given time should be the sum of the cooling from all blocks, considering that blocks were also added earlier.
Additionally, if I set a total mass Mass_setpoint after which I start removing material from the tank, I would need a script that adds CoolingCalc blocks until their combined mass reaches Mass_setpoint, and then begins removing the earliest blocks that were created.
My understanding is that this requires a dynamic script that creates and deletes these blocks over time.
Is it possible to implement this in MATLAB?
I am grateful for any help you can provide.
Best regards,
clear; clc
t_cycle = 200; % [s] simulation time
T = 303.15; % [K] temperature
P = 1; % [MPa] pressure
% Material related
m_in = 0.001; % [kg/s] inlet flowrate
Mass_setpoint = 0.1; % [kg] set point after which material is removed
m_out = 0.002; % [kg/s] outlet flowrate
Xs = 0.002; % [m^3/kg] Pore volume of material
Q_st = 450; % [kJ/kg] Isosteric heat of material
Xeq0 = 1; % Initial value of X
% Plot
[Q_cooling] = CoolingCalc(T, P, Q_st, Xs, Xeq0, m_in, t_cycle);
plot(Q_cooling)
hold on Dear all,
I wrote a function CoolingCalc that calculates the cooling of a porous material based on the input conditions. I want to simulate adding material into a tank at a certain rate per second (m_in). If CoolingCalc represents a "block" containing m_in material per second, then the total cooling at a given time should be the sum of the cooling from all blocks, considering that blocks were also added earlier.
Additionally, if I set a total mass Mass_setpoint after which I start removing material from the tank, I would need a script that adds CoolingCalc blocks until their combined mass reaches Mass_setpoint, and then begins removing the earliest blocks that were created.
My understanding is that this requires a dynamic script that creates and deletes these blocks over time.
Is it possible to implement this in MATLAB?
I am grateful for any help you can provide.
Best regards,
clear; clc
t_cycle = 200; % [s] simulation time
T = 303.15; % [K] temperature
P = 1; % [MPa] pressure
% Material related
m_in = 0.001; % [kg/s] inlet flowrate
Mass_setpoint = 0.1; % [kg] set point after which material is removed
m_out = 0.002; % [kg/s] outlet flowrate
Xs = 0.002; % [m^3/kg] Pore volume of material
Q_st = 450; % [kJ/kg] Isosteric heat of material
Xeq0 = 1; % Initial value of X
% Plot
[Q_cooling] = CoolingCalc(T, P, Q_st, Xs, Xeq0, m_in, t_cycle);
plot(Q_cooling)
hold on dynamic script MATLAB Answers — New Questions