Category: Matlab
Category Archives: Matlab
HTML file to PDF file, deal with base64,svg picture problem solution.
HTML file to PDF file, error when processing base64,svg imagesHTML file to PDF file, error when processing base64,svg images HTML file to PDF file, error when processing base64,svg images html, simulink, pdf MATLAB Answers — New Questions
Include rows containing specific value
I have a 1400*9 table (1400 rows and 9 columns) in MATLAB workspace. Each column has a different name. I want to select rows containing specific value. For example, how can I create a new table containig all rows with value of 0.456 in the column named "Biology"? I tried to use following code, but it gave error.
newData=[Data(find(Data.Biology == 0.456, :))]I have a 1400*9 table (1400 rows and 9 columns) in MATLAB workspace. Each column has a different name. I want to select rows containing specific value. For example, how can I create a new table containig all rows with value of 0.456 in the column named "Biology"? I tried to use following code, but it gave error.
newData=[Data(find(Data.Biology == 0.456, :))] I have a 1400*9 table (1400 rows and 9 columns) in MATLAB workspace. Each column has a different name. I want to select rows containing specific value. For example, how can I create a new table containig all rows with value of 0.456 in the column named "Biology"? I tried to use following code, but it gave error.
newData=[Data(find(Data.Biology == 0.456, :))] table, find MATLAB Answers — New Questions
Force saved figure to use a specific number of pixels
I am saving different maps, I need to compare some specific pixels, but Matlab somehow adds a line at the bottom (3 pixels) for example when I save my image, which kills everything I try to do later. Is there any method to force exportgraphics to use X pixels horizontally and Y vertically (I mean height and width)? Or when I call my figure to be X and Y dimensions? Force it not to add this line. I tried exportgraphics/export_fig they both fail at it.
It is not random, as only some specific files get the line added and always even if I try to replot, I still did not figure out why this happens, my data have the same resolution/grid.I am saving different maps, I need to compare some specific pixels, but Matlab somehow adds a line at the bottom (3 pixels) for example when I save my image, which kills everything I try to do later. Is there any method to force exportgraphics to use X pixels horizontally and Y vertically (I mean height and width)? Or when I call my figure to be X and Y dimensions? Force it not to add this line. I tried exportgraphics/export_fig they both fail at it.
It is not random, as only some specific files get the line added and always even if I try to replot, I still did not figure out why this happens, my data have the same resolution/grid. I am saving different maps, I need to compare some specific pixels, but Matlab somehow adds a line at the bottom (3 pixels) for example when I save my image, which kills everything I try to do later. Is there any method to force exportgraphics to use X pixels horizontally and Y vertically (I mean height and width)? Or when I call my figure to be X and Y dimensions? Force it not to add this line. I tried exportgraphics/export_fig they both fail at it.
It is not random, as only some specific files get the line added and always even if I try to replot, I still did not figure out why this happens, my data have the same resolution/grid. image-processing, exportgraphics MATLAB Answers — New Questions
Working in Excel with live on MATLAB
On matlab, I am going to import an Excel file and work on it live in real time.
If I change the value in Excel, I want to reflect it in real time in MATLAB.
However, as far as I know, if you modify it without saving the Excel, it cannot be applied in MATLAB right away.
Is there a way to solve this?On matlab, I am going to import an Excel file and work on it live in real time.
If I change the value in Excel, I want to reflect it in real time in MATLAB.
However, as far as I know, if you modify it without saving the Excel, it cannot be applied in MATLAB right away.
Is there a way to solve this? On matlab, I am going to import an Excel file and work on it live in real time.
If I change the value in Excel, I want to reflect it in real time in MATLAB.
However, as far as I know, if you modify it without saving the Excel, it cannot be applied in MATLAB right away.
Is there a way to solve this? excel, live MATLAB Answers — New Questions
Logging cmd in multiple diary
Hi,
i’m facing an issue in logging using the matlab ‘diary’ functionality. In the below pseudo-code i have 2 tools and both use diary to log the command window output and one is calling other. The diary off for 2nd tool is terminating the diary for the 1st tool as well due to which the remaining cmd display is not getting logged anywhere.
Here is how the logs are:
Is there a way to use ‘diary’ or some other functionality that would help is logging the command window output for the beow example ?
logger1();
function logger1()
logName = fullfile(pwd, ‘log1.txt’);
diary(logName);
fprintf(‘Initialzing logger 1n’);
fprintf(‘Display Message 1n’);
logger2;
fprintf(‘Display Message 2n’);
fprintf(‘End Logn’);
diary off
end
function logger2()
logName = fullfile(pwd, ‘log2.txt’);
diary(logName);
fprintf(‘Initialzing logger 2n’);
fprintf(‘Display Message 1n’);
fprintf(‘End Logn’);
diary off
endHi,
i’m facing an issue in logging using the matlab ‘diary’ functionality. In the below pseudo-code i have 2 tools and both use diary to log the command window output and one is calling other. The diary off for 2nd tool is terminating the diary for the 1st tool as well due to which the remaining cmd display is not getting logged anywhere.
Here is how the logs are:
Is there a way to use ‘diary’ or some other functionality that would help is logging the command window output for the beow example ?
logger1();
function logger1()
logName = fullfile(pwd, ‘log1.txt’);
diary(logName);
fprintf(‘Initialzing logger 1n’);
fprintf(‘Display Message 1n’);
logger2;
fprintf(‘Display Message 2n’);
fprintf(‘End Logn’);
diary off
end
function logger2()
logName = fullfile(pwd, ‘log2.txt’);
diary(logName);
fprintf(‘Initialzing logger 2n’);
fprintf(‘Display Message 1n’);
fprintf(‘End Logn’);
diary off
end Hi,
i’m facing an issue in logging using the matlab ‘diary’ functionality. In the below pseudo-code i have 2 tools and both use diary to log the command window output and one is calling other. The diary off for 2nd tool is terminating the diary for the 1st tool as well due to which the remaining cmd display is not getting logged anywhere.
Here is how the logs are:
Is there a way to use ‘diary’ or some other functionality that would help is logging the command window output for the beow example ?
logger1();
function logger1()
logName = fullfile(pwd, ‘log1.txt’);
diary(logName);
fprintf(‘Initialzing logger 1n’);
fprintf(‘Display Message 1n’);
logger2;
fprintf(‘Display Message 2n’);
fprintf(‘End Logn’);
diary off
end
function logger2()
logName = fullfile(pwd, ‘log2.txt’);
diary(logName);
fprintf(‘Initialzing logger 2n’);
fprintf(‘Display Message 1n’);
fprintf(‘End Logn’);
diary off
end diary, logging MATLAB Answers — New Questions
Handling memory when working with very huge data (.mat) files.
I am working with two 5D arrays (A5D and B5D) saved in a big_mat_file.mat file. The size of these arrays is specified in the code below. I want to perform three simple operations on these matrices, as shown in the code. I have access to my university’s computing cluster. When I run the following code with 120 workers and 400GB of memory, I receive the following error
In distcomp/remoteparfor/handleIntervalErrorResult (line 245) In distcomp/remoteparfor/getCompleteIntervals (line 395) In parallel_function>distributed_execution (line 746) In parallel_function (line 578)
Can someone please help me understanding what is causing this error. Is it because of low memory? It there anyother way to do the following operattions?
clear; clc;
load("big_mat_file.mat");
% it has two very huge 5D arrays "A5D" and "B5D", and two small arrays "as" and "bs"
% size of both A5D and B5D is [41 16 8 80 82]
% size of "as" is [1 80] and size of "bs" is [1 82]
xs = -12:0.1:12;
NX = length(xs);
ys = 0:0.4:12;
NY = length(ys);
total_iterations = NX * NY;
results = zeros(total_iterations , 41 , 16, 8);
XXs = zeros(total_iterations, 1);
YYs = zeros(total_iterations, 1);
parfor idx = 1:total_iterations
[ix, iy] = ind2sub([NX, NY], idx);
x = xs(ix);
y = ys(iy);
term1 = 1./(exp(1/y*(A5D-x)) + 10); %operation 1
to_integrate = B5D.*term1; %operation 2
XXs(idx) = x;
YYs(idx) = y;
results(idx, :, :, 🙂 = trapz(as,trapz(bs,to_integrate,5),4); %operation 3
end
XXs = reshape(XXs, [NX, NY]);
YYs = reshape(YYs, [NX, NY]);
results = reshape(results, [NX, NY, 41, 16, 8]);
clear A5D B5D
save(‘saved_data.mat’,’-v7.3′);I am working with two 5D arrays (A5D and B5D) saved in a big_mat_file.mat file. The size of these arrays is specified in the code below. I want to perform three simple operations on these matrices, as shown in the code. I have access to my university’s computing cluster. When I run the following code with 120 workers and 400GB of memory, I receive the following error
In distcomp/remoteparfor/handleIntervalErrorResult (line 245) In distcomp/remoteparfor/getCompleteIntervals (line 395) In parallel_function>distributed_execution (line 746) In parallel_function (line 578)
Can someone please help me understanding what is causing this error. Is it because of low memory? It there anyother way to do the following operattions?
clear; clc;
load("big_mat_file.mat");
% it has two very huge 5D arrays "A5D" and "B5D", and two small arrays "as" and "bs"
% size of both A5D and B5D is [41 16 8 80 82]
% size of "as" is [1 80] and size of "bs" is [1 82]
xs = -12:0.1:12;
NX = length(xs);
ys = 0:0.4:12;
NY = length(ys);
total_iterations = NX * NY;
results = zeros(total_iterations , 41 , 16, 8);
XXs = zeros(total_iterations, 1);
YYs = zeros(total_iterations, 1);
parfor idx = 1:total_iterations
[ix, iy] = ind2sub([NX, NY], idx);
x = xs(ix);
y = ys(iy);
term1 = 1./(exp(1/y*(A5D-x)) + 10); %operation 1
to_integrate = B5D.*term1; %operation 2
XXs(idx) = x;
YYs(idx) = y;
results(idx, :, :, 🙂 = trapz(as,trapz(bs,to_integrate,5),4); %operation 3
end
XXs = reshape(XXs, [NX, NY]);
YYs = reshape(YYs, [NX, NY]);
results = reshape(results, [NX, NY, 41, 16, 8]);
clear A5D B5D
save(‘saved_data.mat’,’-v7.3′); I am working with two 5D arrays (A5D and B5D) saved in a big_mat_file.mat file. The size of these arrays is specified in the code below. I want to perform three simple operations on these matrices, as shown in the code. I have access to my university’s computing cluster. When I run the following code with 120 workers and 400GB of memory, I receive the following error
In distcomp/remoteparfor/handleIntervalErrorResult (line 245) In distcomp/remoteparfor/getCompleteIntervals (line 395) In parallel_function>distributed_execution (line 746) In parallel_function (line 578)
Can someone please help me understanding what is causing this error. Is it because of low memory? It there anyother way to do the following operattions?
clear; clc;
load("big_mat_file.mat");
% it has two very huge 5D arrays "A5D" and "B5D", and two small arrays "as" and "bs"
% size of both A5D and B5D is [41 16 8 80 82]
% size of "as" is [1 80] and size of "bs" is [1 82]
xs = -12:0.1:12;
NX = length(xs);
ys = 0:0.4:12;
NY = length(ys);
total_iterations = NX * NY;
results = zeros(total_iterations , 41 , 16, 8);
XXs = zeros(total_iterations, 1);
YYs = zeros(total_iterations, 1);
parfor idx = 1:total_iterations
[ix, iy] = ind2sub([NX, NY], idx);
x = xs(ix);
y = ys(iy);
term1 = 1./(exp(1/y*(A5D-x)) + 10); %operation 1
to_integrate = B5D.*term1; %operation 2
XXs(idx) = x;
YYs(idx) = y;
results(idx, :, :, 🙂 = trapz(as,trapz(bs,to_integrate,5),4); %operation 3
end
XXs = reshape(XXs, [NX, NY]);
YYs = reshape(YYs, [NX, NY]);
results = reshape(results, [NX, NY, 41, 16, 8]);
clear A5D B5D
save(‘saved_data.mat’,’-v7.3′); parfor, for loop, performance MATLAB Answers — New Questions
MATLAB code for multi-step differential transform method (MsDTM) for solving system of differential equations
By starting from the standard DTM from this link
https://www.mathworks.com/matlabcentral/answers/2107386-how-to-solve-sir-model-with-using-dtm-differential-transform-method?s_tid=srchtitle
Can anyone help me to adapt the code to MsDTM? Thank youBy starting from the standard DTM from this link
https://www.mathworks.com/matlabcentral/answers/2107386-how-to-solve-sir-model-with-using-dtm-differential-transform-method?s_tid=srchtitle
Can anyone help me to adapt the code to MsDTM? Thank you By starting from the standard DTM from this link
https://www.mathworks.com/matlabcentral/answers/2107386-how-to-solve-sir-model-with-using-dtm-differential-transform-method?s_tid=srchtitle
Can anyone help me to adapt the code to MsDTM? Thank you dtm, differential transform method, differential equations MATLAB Answers — New Questions
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
I uses cosimulationConfiguration to create a HDL cosimulation block.
I get the following errors
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
Socket connection was closed by the other side
Error in CosimWizardPkg.CosimWizardData/autoFillAllModulesParameters
Error in CosimWizardPkg.ModuleSelection/onNext
Error in CosimWizardPkg.CosimWizardDlg/onNext
Error in cosimulationConfiguration/l_Step4
Error in cosimulationConfiguration/runWorkflow
Error in CosimCommandLineSimulink (line 56)
runWorkflow(c);
Scripts are as follows
%% CosimCommandLineSimulink.m
%% Configure Cosimulation Workflow
% Create a cosimulation configuration object.
%%
c = cosimulationConfiguration(‘Xcelium’,’Simulink’,’top’);
%%
% Set up the HDL file.
%%
c.HDLFiles = {…
‘./src/top.v’, ‘Verilog’,…
‘./src/model.v’, ‘Verilog’,…
};
%%
% Compilation Command
%%
c.HDLCompilationCommand ="xmsc -64bit ./src/model.cpp;" + …
"xmvlog -64bit ./src/top.v ./src/model.v;" + …
"g++ -m64 -o model.o -DNCSC -DCADENCE -D_GLIBCXX_USE_CXX11_ABI=1 " + …
"-DLNX86 -I -I /tools/cds/xceliummain_22.09.004_Linux//tools/systemc/include_pch/64bit " + …
"-I ${TOOL_PATH}/tools/systemc/include/ " + …
"-I ${TOOL_PATH}/tools.lnx86/include " + …
"-I ${TOOL_PATH}/tools/tbsc/include " + …
"-I ${TOOL_PATH}/tools/vic/include " + …
"-c -Wall ./src/*.cpp -fPIC;"+ …
"g++ -m64 -shared -Wl,-G "+ …
"-o systemc.so *.o "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoSim_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoroutines_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libsystemc_sh.so;"+ …
"g++ -m64 -shared -Wl,-G "+ …
"-o systemc.so *.o "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoSim_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoroutines_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libsystemc_sh.so";
%%
% Elaboration
%%
c.HDLElaborationOptions = ‘-64bit -access +wc -messages -loadsc ${PATH}/systemc’;
%%
% Set the clock to a period of 20 ns, and set the reset duration to 15 ns.
%%
specifyClock(c,’clk’,Period=20)
specifyReset(c,’reset’,Duration=15)
specifyInput(c,{‘clk_enable’,’data’,’inv’});
specifyOutput(c,{‘out’});
%%
% Display the port table. It reflects the
% settings just made for output, clock, and reset attributes. The other
% design ports will take on default attributes.
%%
portInterface(c);
%% Generate HDL Cosimulation Block
% Run the workflow to generate an HDL Cosimulation block and the
% accompanying files.
%%
runWorkflow(c);
Complete output when running CosimCommandLineSimulink.m
>> CosimCommandLineSimulink
—– Input Data Ports —–
3×1 table
Name
______________
{‘clk_enable’}
{‘data’ }
{‘inv’ }
—– Output Data Ports —–
2×5 table
Name SampleTime DataType Signed FractionLength
_____________________________ __________ ___________ ______ ______________
{‘default_output_definition’} 1 {‘Inherit’} true 0
{‘out’ } 1 {‘Inherit’} true 0
—– Clock Ports —–
2×3 table
Name Edge Period
____________________________ __________ ______
{‘default_clock_definition’} {‘Rising’} 10
{‘clk’ } {‘Rising’} 20
—– Reset Ports —–
2×3 table
Name InitialValue Duration
____________________________ ____________ ________
{‘default_reset_definition’} 1 8
{‘reset’ } 1 15
—– Unused Ports —–
0×1 empty table
——————– Step 1——————
Select the type of cosimulation you want to do. If the HDL simulator executable you want to use is not on the system path in your environment, you must specify its location.
——————– Step 2——————
Add all VHDL, Verilog, and/or script files to be used in cosimulation to the following table. If the file type cannot be automatically detected or the detection result is incorrect, specify the correct file type in the table. If possible, we will determine the compilation order automatically using HDL simulator provided functionality. Then the HDL files can be added in any order.
——————– Step 3——————
HDL Verifier has automatically generated the following HDL compilation commands. You can customize these commands with optional parameters as specified in the HDL simulator documentation but they are sufficient as shown to compile your HDL code for cosimulation. The HDL files will be compiled when you click Next.
Compiling HDL files. Please wait …
### Compiling HDL design
xmsc(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
xmsc: [TOOL PATH]/tools/cdsgcc/gcc/9.3/bin/g++ -DNCSC -DCADENCE -DLNX86 -D_GLIBCXX_USE_CXX11_ABI=1 -I[TOOL PATH]/systemc/include_pch/64bit -I[TOOL PATH]/tools/systemc/include/tlm2 -I[TOOL PATH]/tools/systemc/include/cci -I[TOOL PATH]/tools/tbsc/include -I[TOOL PATH]/tools/vic/include -c -Wall ./src/model.cpp
xmvlog(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
g++: warning: [TOOL PATH]/tools/systemc/include_pch/64bit: linker input file unused because linking not done
…done
——————– Step 4——————
Specify the name of the HDL module for cosimulation. The Cosimulation Wizard will launch the HDL simulator, load the specified module, and populate the port list of that HDL module before the next step. Use "Shared Memory" communication method if your firewall policy does not allow TCP/IP socket communication.
Elaborating and Loading HDL simulation image. Please wait …
### Elaborating HDL design
### Elaboration command: xmelab -64bit -access +wc -messages -loadsc [PATH]/systemc top
xmelab(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
Elaborating the design hierarchy:
Caching library ‘worklib’ ……. Done
The SystemC(r) Code included in this Product is Copyright 1996 – 2016 by all Contributors. All rights reserved.
The SystemC Code included in this Product has been modified by Cadence Design Systems, Inc. and CoWare, Inc. All such modifications are Copyright (c) 2004-2016 Cadence Design Systems, Inc. and Copyright (c) 2004 CoWare, Inc. All Rights Reserved.
SystemC(r) is a registered trademark of Accellera Systems Initiative, Inc. in the United States and other countries and is used with permission.
Building instance overlay tables: ……………….. Done
Building instance specific data structures.
Loading native compiled code: ……………….. Done
Design hierarchy summary:
Instances Unique
Modules: 2 2
Scalar wires: 6 –
Simulation timescale: 1ns
SystemC Design Summary:
Instances
sc_modules: 1
sc_ports: 5
sc_methods: 1
Writing initial simulation snapshot: worklib.top:module
Waiting for HDL Simulator to startup …
120 seconds to time-out …
To stop this process, press Ctrl+C in MATLAB console.
Waiting for HDL Simulator to startup …
119 seconds to time-out …
To stop this process, press Ctrl+C in MATLAB console.
…done
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
Socket connection was closed by the other side
Error in CosimWizardPkg.CosimWizardData/autoFillAllModulesParameters
Error in CosimWizardPkg.ModuleSelection/onNext
Error in CosimWizardPkg.CosimWizardDlg/onNext
Error in cosimulationConfiguration/l_Step4
Error in cosimulationConfiguration/runWorkflow
Error in CosimCommandLineSimulink (line 56)
runWorkflow(c);
Do you have any idea what is reason?
Note: paths of tools and files are hidden in this question.I uses cosimulationConfiguration to create a HDL cosimulation block.
I get the following errors
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
Socket connection was closed by the other side
Error in CosimWizardPkg.CosimWizardData/autoFillAllModulesParameters
Error in CosimWizardPkg.ModuleSelection/onNext
Error in CosimWizardPkg.CosimWizardDlg/onNext
Error in cosimulationConfiguration/l_Step4
Error in cosimulationConfiguration/runWorkflow
Error in CosimCommandLineSimulink (line 56)
runWorkflow(c);
Scripts are as follows
%% CosimCommandLineSimulink.m
%% Configure Cosimulation Workflow
% Create a cosimulation configuration object.
%%
c = cosimulationConfiguration(‘Xcelium’,’Simulink’,’top’);
%%
% Set up the HDL file.
%%
c.HDLFiles = {…
‘./src/top.v’, ‘Verilog’,…
‘./src/model.v’, ‘Verilog’,…
};
%%
% Compilation Command
%%
c.HDLCompilationCommand ="xmsc -64bit ./src/model.cpp;" + …
"xmvlog -64bit ./src/top.v ./src/model.v;" + …
"g++ -m64 -o model.o -DNCSC -DCADENCE -D_GLIBCXX_USE_CXX11_ABI=1 " + …
"-DLNX86 -I -I /tools/cds/xceliummain_22.09.004_Linux//tools/systemc/include_pch/64bit " + …
"-I ${TOOL_PATH}/tools/systemc/include/ " + …
"-I ${TOOL_PATH}/tools.lnx86/include " + …
"-I ${TOOL_PATH}/tools/tbsc/include " + …
"-I ${TOOL_PATH}/tools/vic/include " + …
"-c -Wall ./src/*.cpp -fPIC;"+ …
"g++ -m64 -shared -Wl,-G "+ …
"-o systemc.so *.o "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoSim_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoroutines_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libsystemc_sh.so;"+ …
"g++ -m64 -shared -Wl,-G "+ …
"-o systemc.so *.o "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoSim_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoroutines_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libsystemc_sh.so";
%%
% Elaboration
%%
c.HDLElaborationOptions = ‘-64bit -access +wc -messages -loadsc ${PATH}/systemc’;
%%
% Set the clock to a period of 20 ns, and set the reset duration to 15 ns.
%%
specifyClock(c,’clk’,Period=20)
specifyReset(c,’reset’,Duration=15)
specifyInput(c,{‘clk_enable’,’data’,’inv’});
specifyOutput(c,{‘out’});
%%
% Display the port table. It reflects the
% settings just made for output, clock, and reset attributes. The other
% design ports will take on default attributes.
%%
portInterface(c);
%% Generate HDL Cosimulation Block
% Run the workflow to generate an HDL Cosimulation block and the
% accompanying files.
%%
runWorkflow(c);
Complete output when running CosimCommandLineSimulink.m
>> CosimCommandLineSimulink
—– Input Data Ports —–
3×1 table
Name
______________
{‘clk_enable’}
{‘data’ }
{‘inv’ }
—– Output Data Ports —–
2×5 table
Name SampleTime DataType Signed FractionLength
_____________________________ __________ ___________ ______ ______________
{‘default_output_definition’} 1 {‘Inherit’} true 0
{‘out’ } 1 {‘Inherit’} true 0
—– Clock Ports —–
2×3 table
Name Edge Period
____________________________ __________ ______
{‘default_clock_definition’} {‘Rising’} 10
{‘clk’ } {‘Rising’} 20
—– Reset Ports —–
2×3 table
Name InitialValue Duration
____________________________ ____________ ________
{‘default_reset_definition’} 1 8
{‘reset’ } 1 15
—– Unused Ports —–
0×1 empty table
——————– Step 1——————
Select the type of cosimulation you want to do. If the HDL simulator executable you want to use is not on the system path in your environment, you must specify its location.
——————– Step 2——————
Add all VHDL, Verilog, and/or script files to be used in cosimulation to the following table. If the file type cannot be automatically detected or the detection result is incorrect, specify the correct file type in the table. If possible, we will determine the compilation order automatically using HDL simulator provided functionality. Then the HDL files can be added in any order.
——————– Step 3——————
HDL Verifier has automatically generated the following HDL compilation commands. You can customize these commands with optional parameters as specified in the HDL simulator documentation but they are sufficient as shown to compile your HDL code for cosimulation. The HDL files will be compiled when you click Next.
Compiling HDL files. Please wait …
### Compiling HDL design
xmsc(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
xmsc: [TOOL PATH]/tools/cdsgcc/gcc/9.3/bin/g++ -DNCSC -DCADENCE -DLNX86 -D_GLIBCXX_USE_CXX11_ABI=1 -I[TOOL PATH]/systemc/include_pch/64bit -I[TOOL PATH]/tools/systemc/include/tlm2 -I[TOOL PATH]/tools/systemc/include/cci -I[TOOL PATH]/tools/tbsc/include -I[TOOL PATH]/tools/vic/include -c -Wall ./src/model.cpp
xmvlog(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
g++: warning: [TOOL PATH]/tools/systemc/include_pch/64bit: linker input file unused because linking not done
…done
——————– Step 4——————
Specify the name of the HDL module for cosimulation. The Cosimulation Wizard will launch the HDL simulator, load the specified module, and populate the port list of that HDL module before the next step. Use "Shared Memory" communication method if your firewall policy does not allow TCP/IP socket communication.
Elaborating and Loading HDL simulation image. Please wait …
### Elaborating HDL design
### Elaboration command: xmelab -64bit -access +wc -messages -loadsc [PATH]/systemc top
xmelab(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
Elaborating the design hierarchy:
Caching library ‘worklib’ ……. Done
The SystemC(r) Code included in this Product is Copyright 1996 – 2016 by all Contributors. All rights reserved.
The SystemC Code included in this Product has been modified by Cadence Design Systems, Inc. and CoWare, Inc. All such modifications are Copyright (c) 2004-2016 Cadence Design Systems, Inc. and Copyright (c) 2004 CoWare, Inc. All Rights Reserved.
SystemC(r) is a registered trademark of Accellera Systems Initiative, Inc. in the United States and other countries and is used with permission.
Building instance overlay tables: ……………….. Done
Building instance specific data structures.
Loading native compiled code: ……………….. Done
Design hierarchy summary:
Instances Unique
Modules: 2 2
Scalar wires: 6 –
Simulation timescale: 1ns
SystemC Design Summary:
Instances
sc_modules: 1
sc_ports: 5
sc_methods: 1
Writing initial simulation snapshot: worklib.top:module
Waiting for HDL Simulator to startup …
120 seconds to time-out …
To stop this process, press Ctrl+C in MATLAB console.
Waiting for HDL Simulator to startup …
119 seconds to time-out …
To stop this process, press Ctrl+C in MATLAB console.
…done
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
Socket connection was closed by the other side
Error in CosimWizardPkg.CosimWizardData/autoFillAllModulesParameters
Error in CosimWizardPkg.ModuleSelection/onNext
Error in CosimWizardPkg.CosimWizardDlg/onNext
Error in cosimulationConfiguration/l_Step4
Error in cosimulationConfiguration/runWorkflow
Error in CosimCommandLineSimulink (line 56)
runWorkflow(c);
Do you have any idea what is reason?
Note: paths of tools and files are hidden in this question. I uses cosimulationConfiguration to create a HDL cosimulation block.
I get the following errors
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
Socket connection was closed by the other side
Error in CosimWizardPkg.CosimWizardData/autoFillAllModulesParameters
Error in CosimWizardPkg.ModuleSelection/onNext
Error in CosimWizardPkg.CosimWizardDlg/onNext
Error in cosimulationConfiguration/l_Step4
Error in cosimulationConfiguration/runWorkflow
Error in CosimCommandLineSimulink (line 56)
runWorkflow(c);
Scripts are as follows
%% CosimCommandLineSimulink.m
%% Configure Cosimulation Workflow
% Create a cosimulation configuration object.
%%
c = cosimulationConfiguration(‘Xcelium’,’Simulink’,’top’);
%%
% Set up the HDL file.
%%
c.HDLFiles = {…
‘./src/top.v’, ‘Verilog’,…
‘./src/model.v’, ‘Verilog’,…
};
%%
% Compilation Command
%%
c.HDLCompilationCommand ="xmsc -64bit ./src/model.cpp;" + …
"xmvlog -64bit ./src/top.v ./src/model.v;" + …
"g++ -m64 -o model.o -DNCSC -DCADENCE -D_GLIBCXX_USE_CXX11_ABI=1 " + …
"-DLNX86 -I -I /tools/cds/xceliummain_22.09.004_Linux//tools/systemc/include_pch/64bit " + …
"-I ${TOOL_PATH}/tools/systemc/include/ " + …
"-I ${TOOL_PATH}/tools.lnx86/include " + …
"-I ${TOOL_PATH}/tools/tbsc/include " + …
"-I ${TOOL_PATH}/tools/vic/include " + …
"-c -Wall ./src/*.cpp -fPIC;"+ …
"g++ -m64 -shared -Wl,-G "+ …
"-o systemc.so *.o "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoSim_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoroutines_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libsystemc_sh.so;"+ …
"g++ -m64 -shared -Wl,-G "+ …
"-o systemc.so *.o "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoSim_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libncscCoroutines_sh.so "+ …
"${TOOL_PATH}/tools/systemc/lib/64bit/libsystemc_sh.so";
%%
% Elaboration
%%
c.HDLElaborationOptions = ‘-64bit -access +wc -messages -loadsc ${PATH}/systemc’;
%%
% Set the clock to a period of 20 ns, and set the reset duration to 15 ns.
%%
specifyClock(c,’clk’,Period=20)
specifyReset(c,’reset’,Duration=15)
specifyInput(c,{‘clk_enable’,’data’,’inv’});
specifyOutput(c,{‘out’});
%%
% Display the port table. It reflects the
% settings just made for output, clock, and reset attributes. The other
% design ports will take on default attributes.
%%
portInterface(c);
%% Generate HDL Cosimulation Block
% Run the workflow to generate an HDL Cosimulation block and the
% accompanying files.
%%
runWorkflow(c);
Complete output when running CosimCommandLineSimulink.m
>> CosimCommandLineSimulink
—– Input Data Ports —–
3×1 table
Name
______________
{‘clk_enable’}
{‘data’ }
{‘inv’ }
—– Output Data Ports —–
2×5 table
Name SampleTime DataType Signed FractionLength
_____________________________ __________ ___________ ______ ______________
{‘default_output_definition’} 1 {‘Inherit’} true 0
{‘out’ } 1 {‘Inherit’} true 0
—– Clock Ports —–
2×3 table
Name Edge Period
____________________________ __________ ______
{‘default_clock_definition’} {‘Rising’} 10
{‘clk’ } {‘Rising’} 20
—– Reset Ports —–
2×3 table
Name InitialValue Duration
____________________________ ____________ ________
{‘default_reset_definition’} 1 8
{‘reset’ } 1 15
—– Unused Ports —–
0×1 empty table
——————– Step 1——————
Select the type of cosimulation you want to do. If the HDL simulator executable you want to use is not on the system path in your environment, you must specify its location.
——————– Step 2——————
Add all VHDL, Verilog, and/or script files to be used in cosimulation to the following table. If the file type cannot be automatically detected or the detection result is incorrect, specify the correct file type in the table. If possible, we will determine the compilation order automatically using HDL simulator provided functionality. Then the HDL files can be added in any order.
——————– Step 3——————
HDL Verifier has automatically generated the following HDL compilation commands. You can customize these commands with optional parameters as specified in the HDL simulator documentation but they are sufficient as shown to compile your HDL code for cosimulation. The HDL files will be compiled when you click Next.
Compiling HDL files. Please wait …
### Compiling HDL design
xmsc(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
xmsc: [TOOL PATH]/tools/cdsgcc/gcc/9.3/bin/g++ -DNCSC -DCADENCE -DLNX86 -D_GLIBCXX_USE_CXX11_ABI=1 -I[TOOL PATH]/systemc/include_pch/64bit -I[TOOL PATH]/tools/systemc/include/tlm2 -I[TOOL PATH]/tools/systemc/include/cci -I[TOOL PATH]/tools/tbsc/include -I[TOOL PATH]/tools/vic/include -c -Wall ./src/model.cpp
xmvlog(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
g++: warning: [TOOL PATH]/tools/systemc/include_pch/64bit: linker input file unused because linking not done
…done
——————– Step 4——————
Specify the name of the HDL module for cosimulation. The Cosimulation Wizard will launch the HDL simulator, load the specified module, and populate the port list of that HDL module before the next step. Use "Shared Memory" communication method if your firewall policy does not allow TCP/IP socket communication.
Elaborating and Loading HDL simulation image. Please wait …
### Elaborating HDL design
### Elaboration command: xmelab -64bit -access +wc -messages -loadsc [PATH]/systemc top
xmelab(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
Elaborating the design hierarchy:
Caching library ‘worklib’ ……. Done
The SystemC(r) Code included in this Product is Copyright 1996 – 2016 by all Contributors. All rights reserved.
The SystemC Code included in this Product has been modified by Cadence Design Systems, Inc. and CoWare, Inc. All such modifications are Copyright (c) 2004-2016 Cadence Design Systems, Inc. and Copyright (c) 2004 CoWare, Inc. All Rights Reserved.
SystemC(r) is a registered trademark of Accellera Systems Initiative, Inc. in the United States and other countries and is used with permission.
Building instance overlay tables: ……………….. Done
Building instance specific data structures.
Loading native compiled code: ……………….. Done
Design hierarchy summary:
Instances Unique
Modules: 2 2
Scalar wires: 6 –
Simulation timescale: 1ns
SystemC Design Summary:
Instances
sc_modules: 1
sc_ports: 5
sc_methods: 1
Writing initial simulation snapshot: worklib.top:module
Waiting for HDL Simulator to startup …
120 seconds to time-out …
To stop this process, press Ctrl+C in MATLAB console.
Waiting for HDL Simulator to startup …
119 seconds to time-out …
To stop this process, press Ctrl+C in MATLAB console.
…done
Error using CosimWizardPkg.CosimWizardData/populateHdlHierarchy
Socket connection was closed by the other side
Error in CosimWizardPkg.CosimWizardData/autoFillAllModulesParameters
Error in CosimWizardPkg.ModuleSelection/onNext
Error in CosimWizardPkg.CosimWizardDlg/onNext
Error in cosimulationConfiguration/l_Step4
Error in cosimulationConfiguration/runWorkflow
Error in CosimCommandLineSimulink (line 56)
runWorkflow(c);
Do you have any idea what is reason?
Note: paths of tools and files are hidden in this question. hdlverifier, cosimulationconfiguration, simulink, cadence, xcelium MATLAB Answers — New Questions
MATLAB standalone app installation without administrator
Hi,
I am trying to make some MATLAB apps for people without MATLAB licenses at work. I compiled them as standalone apps with the runtime libraries included in the package so they don’t have to be downloaded and installed separately. However, the app requires admin privileges to install. This isn’t very pleasant since we have to request IT for each installation.
Is there a way to eliminate the need for administrator privileges? I tried moving the installation directory to the user directory instead of Program Files but that didn’t help as well.
Thanks,
AbinavHi,
I am trying to make some MATLAB apps for people without MATLAB licenses at work. I compiled them as standalone apps with the runtime libraries included in the package so they don’t have to be downloaded and installed separately. However, the app requires admin privileges to install. This isn’t very pleasant since we have to request IT for each installation.
Is there a way to eliminate the need for administrator privileges? I tried moving the installation directory to the user directory instead of Program Files but that didn’t help as well.
Thanks,
Abinav Hi,
I am trying to make some MATLAB apps for people without MATLAB licenses at work. I compiled them as standalone apps with the runtime libraries included in the package so they don’t have to be downloaded and installed separately. However, the app requires admin privileges to install. This isn’t very pleasant since we have to request IT for each installation.
Is there a way to eliminate the need for administrator privileges? I tried moving the installation directory to the user directory instead of Program Files but that didn’t help as well.
Thanks,
Abinav matlab app, matlab compiler, administrator MATLAB Answers — New Questions
Where are “files installed for your end user” are saved in the installation directory using compiler?
I have a few matrices that I want to load in the app using the load command.
Temporarily the files are saved like this:
load C:UserssepandDocumentsMATLABBY.mat;
what path should I set them to so that they would be accessible to the main program after compilation?I have a few matrices that I want to load in the app using the load command.
Temporarily the files are saved like this:
load C:UserssepandDocumentsMATLABBY.mat;
what path should I set them to so that they would be accessible to the main program after compilation? I have a few matrices that I want to load in the app using the load command.
Temporarily the files are saved like this:
load C:UserssepandDocumentsMATLABBY.mat;
what path should I set them to so that they would be accessible to the main program after compilation? matlab compiler MATLAB Answers — New Questions
Confirming a confirmed track for GNN tracker
Hi, I am currently working with a GNN tracker with radar data. I have a tracker working for range and angle information.
After gettting the confirmed tracks, I would like to check make another check with some detections and then keep the old track alive. How can I achieve this? I saw that there is a trackStateLogic which is appended with a zero everytime a track does not get a detection. But I was uable to change it for a confirmed track.
Can someone please help me in this?Hi, I am currently working with a GNN tracker with radar data. I have a tracker working for range and angle information.
After gettting the confirmed tracks, I would like to check make another check with some detections and then keep the old track alive. How can I achieve this? I saw that there is a trackStateLogic which is appended with a zero everytime a track does not get a detection. But I was uable to change it for a confirmed track.
Can someone please help me in this? Hi, I am currently working with a GNN tracker with radar data. I have a tracker working for range and angle information.
After gettting the confirmed tracks, I would like to check make another check with some detections and then keep the old track alive. How can I achieve this? I saw that there is a trackStateLogic which is appended with a zero everytime a track does not get a detection. But I was uable to change it for a confirmed track.
Can someone please help me in this? gnn tracker MATLAB Answers — New Questions
Efficient Code for Filling Rows of an Array involving Indices Ranges
Hello,
I have an array A of zeros. I need to set a range of column indices for each row of A to ones. These ranges are determined by elements of another vector B, specifying start and end indices for the ranges for each row. For example, this is what I’m trying to figure out:
<</matlabcentral/answers/uploaded_files/18907/matrixA.jpg>>
<</matlabcentral/answers/uploaded_files/18908/matrixB.jpg>>
<</matlabcentral/answers/uploaded_files/18909/matrixA2.jpg>>
The first row of B indicates that the first row of A should have ones from columns 1 to 3. The second row of B indicates that the second row of A should have ones from columns 2 to 4 etc.
I could code this with a for-loop that goes through each of the rows and creates indices with the colon operator however, I’m hoping for a smarter, more efficient way to do it than that.
Can anyone help me with this or any suggestions?
Thanks.Hello,
I have an array A of zeros. I need to set a range of column indices for each row of A to ones. These ranges are determined by elements of another vector B, specifying start and end indices for the ranges for each row. For example, this is what I’m trying to figure out:
<</matlabcentral/answers/uploaded_files/18907/matrixA.jpg>>
<</matlabcentral/answers/uploaded_files/18908/matrixB.jpg>>
<</matlabcentral/answers/uploaded_files/18909/matrixA2.jpg>>
The first row of B indicates that the first row of A should have ones from columns 1 to 3. The second row of B indicates that the second row of A should have ones from columns 2 to 4 etc.
I could code this with a for-loop that goes through each of the rows and creates indices with the colon operator however, I’m hoping for a smarter, more efficient way to do it than that.
Can anyone help me with this or any suggestions?
Thanks. Hello,
I have an array A of zeros. I need to set a range of column indices for each row of A to ones. These ranges are determined by elements of another vector B, specifying start and end indices for the ranges for each row. For example, this is what I’m trying to figure out:
<</matlabcentral/answers/uploaded_files/18907/matrixA.jpg>>
<</matlabcentral/answers/uploaded_files/18908/matrixB.jpg>>
<</matlabcentral/answers/uploaded_files/18909/matrixA2.jpg>>
The first row of B indicates that the first row of A should have ones from columns 1 to 3. The second row of B indicates that the second row of A should have ones from columns 2 to 4 etc.
I could code this with a for-loop that goes through each of the rows and creates indices with the colon operator however, I’m hoping for a smarter, more efficient way to do it than that.
Can anyone help me with this or any suggestions?
Thanks. matrix manipulation MATLAB Answers — New Questions
Uigetdir to pick multiple directories
I was wondering if anyone knows a simple way how to use uigetdir to select multiple directory paths in a similar way to using uigetfile with ‘multiselect’,’on’
ThanksI was wondering if anyone knows a simple way how to use uigetdir to select multiple directory paths in a similar way to using uigetfile with ‘multiselect’,’on’
Thanks I was wondering if anyone knows a simple way how to use uigetdir to select multiple directory paths in a similar way to using uigetfile with ‘multiselect’,’on’
Thanks uigetdir, uigetfile, multiselect, directory MATLAB Answers — New Questions
Combined 2 files .dat with different size
hello i have 2 files .dat contains enum values but the size of the file one 4000×2 and the second 6000×2 i use "csvread" and "readmatrix" but doesn’t work
Note (enum :enumeration)
can you help me pls
thankshello i have 2 files .dat contains enum values but the size of the file one 4000×2 and the second 6000×2 i use "csvread" and "readmatrix" but doesn’t work
Note (enum :enumeration)
can you help me pls
thanks hello i have 2 files .dat contains enum values but the size of the file one 4000×2 and the second 6000×2 i use "csvread" and "readmatrix" but doesn’t work
Note (enum :enumeration)
can you help me pls
thanks matlab, .dat MATLAB Answers — New Questions
How do I incorporate a feedforward control signal into an MPC block?
I have designed a feedback control system using an Model Predictive Controller block for a DC Motor servomechanism. In order to reduce the steady-state error I want to include a feedforward control signal that I can estimate and predict. The MPC block therefore needs to have knowledge of the feedforward control signal as, I assume, a measured disturbance which is able to be previewed. I have implemented this as below:
I haven’t been able to improve the controller performance with this architecture as I would expect (previous PI + Feedforward works very well), so I wanted to ask whether this was the correct approach to include the feedforward signal into the MPC block?I have designed a feedback control system using an Model Predictive Controller block for a DC Motor servomechanism. In order to reduce the steady-state error I want to include a feedforward control signal that I can estimate and predict. The MPC block therefore needs to have knowledge of the feedforward control signal as, I assume, a measured disturbance which is able to be previewed. I have implemented this as below:
I haven’t been able to improve the controller performance with this architecture as I would expect (previous PI + Feedforward works very well), so I wanted to ask whether this was the correct approach to include the feedforward signal into the MPC block? I have designed a feedback control system using an Model Predictive Controller block for a DC Motor servomechanism. In order to reduce the steady-state error I want to include a feedforward control signal that I can estimate and predict. The MPC block therefore needs to have knowledge of the feedforward control signal as, I assume, a measured disturbance which is able to be previewed. I have implemented this as below:
I haven’t been able to improve the controller performance with this architecture as I would expect (previous PI + Feedforward works very well), so I wanted to ask whether this was the correct approach to include the feedforward signal into the MPC block? mpc, simulink, feedforward, control MATLAB Answers — New Questions
Need help to removing motion (breathing?) artifact from ECG signal
I have this single-channel ECG signal with motion artifacts (I believe from breathing).
I’ve tried several filters, but none have given me a good output.
Not being an expert, I followed the instructions from Kher, 2019 with this code, but a compatibility issue (since I am using version 2018b) prevents me from obtaining any results; by changing some commands the result is unsuitable:
y1 = load(‘EKG.mat’);
y2= (y1 (:,1)); % ECG signal data
a1= (y1 (:,1)); % accelerometer x-axis data
a2= (y1 (:,1)); % accelerometer y-axis data
a3= (y1 (:,1)); % accelerometer z-axis data
y2 = y2/max(y2);
Subplot (3, 1, 1), plot (y2), title (‘ECG Signal with motion artifacts’), grid on
a = a1+a2+a3;
a = a/max(a);
mu= 0.0008;
%Hd = adaptfilt.lms(32, mu); %original command
Hd = dsp.LMSFilter(‘Length’, 32, ‘StepSize’, mu);
% [s2, e] = filter(Hd, a, y2); % original command, don’t work in 2018b version
[s2, e] = Hd(a, y2); % command adapted
fig = figure
subplot (3, 1, 2)
plot (s2)
title (‘Noise (motion artifact) estimate’)
grid on
subplot (3, 1, 3)
plot (e)
title (‘Adaptively filtered/ Noise free ECG signal’)
grid on
I also tried filtering in this other way, but the result is very poor.
ecg_signal = load(‘EKG.mat’);
Fs = 256;
t = (0:length(ecg_signal)-1) / Fs;
fc = 45; % cut frequency
[b, a] = butter(4, fc / (Fs / 2), ‘low’);
% filter
ecg_filtered = filtfilt(b, a, ecg_signal);
With simple low-pass or high-pass filters I wasn’t able to obtain at least acceptable results.
If anyone can help me?
thank you in advanceI have this single-channel ECG signal with motion artifacts (I believe from breathing).
I’ve tried several filters, but none have given me a good output.
Not being an expert, I followed the instructions from Kher, 2019 with this code, but a compatibility issue (since I am using version 2018b) prevents me from obtaining any results; by changing some commands the result is unsuitable:
y1 = load(‘EKG.mat’);
y2= (y1 (:,1)); % ECG signal data
a1= (y1 (:,1)); % accelerometer x-axis data
a2= (y1 (:,1)); % accelerometer y-axis data
a3= (y1 (:,1)); % accelerometer z-axis data
y2 = y2/max(y2);
Subplot (3, 1, 1), plot (y2), title (‘ECG Signal with motion artifacts’), grid on
a = a1+a2+a3;
a = a/max(a);
mu= 0.0008;
%Hd = adaptfilt.lms(32, mu); %original command
Hd = dsp.LMSFilter(‘Length’, 32, ‘StepSize’, mu);
% [s2, e] = filter(Hd, a, y2); % original command, don’t work in 2018b version
[s2, e] = Hd(a, y2); % command adapted
fig = figure
subplot (3, 1, 2)
plot (s2)
title (‘Noise (motion artifact) estimate’)
grid on
subplot (3, 1, 3)
plot (e)
title (‘Adaptively filtered/ Noise free ECG signal’)
grid on
I also tried filtering in this other way, but the result is very poor.
ecg_signal = load(‘EKG.mat’);
Fs = 256;
t = (0:length(ecg_signal)-1) / Fs;
fc = 45; % cut frequency
[b, a] = butter(4, fc / (Fs / 2), ‘low’);
% filter
ecg_filtered = filtfilt(b, a, ecg_signal);
With simple low-pass or high-pass filters I wasn’t able to obtain at least acceptable results.
If anyone can help me?
thank you in advance I have this single-channel ECG signal with motion artifacts (I believe from breathing).
I’ve tried several filters, but none have given me a good output.
Not being an expert, I followed the instructions from Kher, 2019 with this code, but a compatibility issue (since I am using version 2018b) prevents me from obtaining any results; by changing some commands the result is unsuitable:
y1 = load(‘EKG.mat’);
y2= (y1 (:,1)); % ECG signal data
a1= (y1 (:,1)); % accelerometer x-axis data
a2= (y1 (:,1)); % accelerometer y-axis data
a3= (y1 (:,1)); % accelerometer z-axis data
y2 = y2/max(y2);
Subplot (3, 1, 1), plot (y2), title (‘ECG Signal with motion artifacts’), grid on
a = a1+a2+a3;
a = a/max(a);
mu= 0.0008;
%Hd = adaptfilt.lms(32, mu); %original command
Hd = dsp.LMSFilter(‘Length’, 32, ‘StepSize’, mu);
% [s2, e] = filter(Hd, a, y2); % original command, don’t work in 2018b version
[s2, e] = Hd(a, y2); % command adapted
fig = figure
subplot (3, 1, 2)
plot (s2)
title (‘Noise (motion artifact) estimate’)
grid on
subplot (3, 1, 3)
plot (e)
title (‘Adaptively filtered/ Noise free ECG signal’)
grid on
I also tried filtering in this other way, but the result is very poor.
ecg_signal = load(‘EKG.mat’);
Fs = 256;
t = (0:length(ecg_signal)-1) / Fs;
fc = 45; % cut frequency
[b, a] = butter(4, fc / (Fs / 2), ‘low’);
% filter
ecg_filtered = filtfilt(b, a, ecg_signal);
With simple low-pass or high-pass filters I wasn’t able to obtain at least acceptable results.
If anyone can help me?
thank you in advance filter, artifact MATLAB Answers — New Questions
How can I have the middle data set during the fitting process by lsqcurvefit?
How can I have the middle data sets during the fitting process by lsqcurvefit?
By x = lsqcurvefit(fun,x0,xdata,ydata), x0 is initail data set and x is final data set.
I need the middle data sets. if possible, could you let me know how to get the middle data sets?
I’d like to make some graphs with middle data sets by fun in order to compare the grapfs differences.
I tried multiple lsqcurvefit, which means the below process. But, it needs so many hours….
calculate the x by lsqcurvefit and have the loop number. e.g. loop number = 100
set MaxIterations as 10 and calculate the x10 by lsqcurvefit
set MaxIterations as 20, 30,,,,100 and calculate the x20, x30,,,x100, respectivelly by lsqcurvefit
make the graphs with x10,x20,,,x100How can I have the middle data sets during the fitting process by lsqcurvefit?
By x = lsqcurvefit(fun,x0,xdata,ydata), x0 is initail data set and x is final data set.
I need the middle data sets. if possible, could you let me know how to get the middle data sets?
I’d like to make some graphs with middle data sets by fun in order to compare the grapfs differences.
I tried multiple lsqcurvefit, which means the below process. But, it needs so many hours….
calculate the x by lsqcurvefit and have the loop number. e.g. loop number = 100
set MaxIterations as 10 and calculate the x10 by lsqcurvefit
set MaxIterations as 20, 30,,,,100 and calculate the x20, x30,,,x100, respectivelly by lsqcurvefit
make the graphs with x10,x20,,,x100 How can I have the middle data sets during the fitting process by lsqcurvefit?
By x = lsqcurvefit(fun,x0,xdata,ydata), x0 is initail data set and x is final data set.
I need the middle data sets. if possible, could you let me know how to get the middle data sets?
I’d like to make some graphs with middle data sets by fun in order to compare the grapfs differences.
I tried multiple lsqcurvefit, which means the below process. But, it needs so many hours….
calculate the x by lsqcurvefit and have the loop number. e.g. loop number = 100
set MaxIterations as 10 and calculate the x10 by lsqcurvefit
set MaxIterations as 20, 30,,,,100 and calculate the x20, x30,,,x100, respectivelly by lsqcurvefit
make the graphs with x10,x20,,,x100 lsqcurvefit, middle data, plot MATLAB Answers — New Questions
MATLAB Plots *.tif According to Light
Hi,
I am trying to plot a lunar terrain from a *.stl file. You can see the real image and plot in photos. MATLAB is plotting the deepest place as dark blue, the highest as yellow, but the thing is MATLAB’s dark blue is not actually the deepest place, it is just shadow, likewise MATLAB’s yellow actually isn’t the highest place, it just takes the most light so its brighter. This is my code snippet to plot it. My real aim is to create a simulation, therefore I need the surface model.
[dem, ~] = readgeoraster(‘moon1m-a.tif’);
gridSize = 3900;
start = 1;
[X, Y] = meshgrid(1:gridSize, 1:gridSize);
Z = dem(start:start+gridSize-1, start+gridSize-1:-1:start);
figure
mesh(X, Y, Z);
Images are aligned, you can see the shadow places at the bottom right.
I can’t put the file into the attachments, it is too big even after compressing. I can put the *.tif into a 3D drawing tool, this is the output.
Any help would be appreciated.
Thanks in advance.Hi,
I am trying to plot a lunar terrain from a *.stl file. You can see the real image and plot in photos. MATLAB is plotting the deepest place as dark blue, the highest as yellow, but the thing is MATLAB’s dark blue is not actually the deepest place, it is just shadow, likewise MATLAB’s yellow actually isn’t the highest place, it just takes the most light so its brighter. This is my code snippet to plot it. My real aim is to create a simulation, therefore I need the surface model.
[dem, ~] = readgeoraster(‘moon1m-a.tif’);
gridSize = 3900;
start = 1;
[X, Y] = meshgrid(1:gridSize, 1:gridSize);
Z = dem(start:start+gridSize-1, start+gridSize-1:-1:start);
figure
mesh(X, Y, Z);
Images are aligned, you can see the shadow places at the bottom right.
I can’t put the file into the attachments, it is too big even after compressing. I can put the *.tif into a 3D drawing tool, this is the output.
Any help would be appreciated.
Thanks in advance. Hi,
I am trying to plot a lunar terrain from a *.stl file. You can see the real image and plot in photos. MATLAB is plotting the deepest place as dark blue, the highest as yellow, but the thing is MATLAB’s dark blue is not actually the deepest place, it is just shadow, likewise MATLAB’s yellow actually isn’t the highest place, it just takes the most light so its brighter. This is my code snippet to plot it. My real aim is to create a simulation, therefore I need the surface model.
[dem, ~] = readgeoraster(‘moon1m-a.tif’);
gridSize = 3900;
start = 1;
[X, Y] = meshgrid(1:gridSize, 1:gridSize);
Z = dem(start:start+gridSize-1, start+gridSize-1:-1:start);
figure
mesh(X, Y, Z);
Images are aligned, you can see the shadow places at the bottom right.
I can’t put the file into the attachments, it is too big even after compressing. I can put the *.tif into a 3D drawing tool, this is the output.
Any help would be appreciated.
Thanks in advance. 3d plots, plot, mesh, figure MATLAB Answers — New Questions
Mimic axis equal in secondary y-axis
Is there a way to mimc ‘axis equal’ for a secondary axis? ‘Axis equal’ doesn’t work when using yyaxis(ax,’right’).
In addtion, the mimic should resize the same as if ‘axis equal’ was called on a single plot.Is there a way to mimc ‘axis equal’ for a secondary axis? ‘Axis equal’ doesn’t work when using yyaxis(ax,’right’).
In addtion, the mimic should resize the same as if ‘axis equal’ was called on a single plot. Is there a way to mimc ‘axis equal’ for a secondary axis? ‘Axis equal’ doesn’t work when using yyaxis(ax,’right’).
In addtion, the mimic should resize the same as if ‘axis equal’ was called on a single plot. axis equal, axis, equal MATLAB Answers — New Questions
t test for two samples with different sizes
Hi,
Which function should i use if I want to test whether two samples with different sizes have different means? I see many ttest functions in matlabHi,
Which function should i use if I want to test whether two samples with different sizes have different means? I see many ttest functions in matlab Hi,
Which function should i use if I want to test whether two samples with different sizes have different means? I see many ttest functions in matlab t test MATLAB Answers — New Questions