Tag Archives: matlab
How can you use MATLAB Grader in Moodle Quizzes?
MATLAB Grader can be integrated into Moodle as an external tool. How can you use MATLAB Grader in Moodle Quizzes, to implement MATLAB Grader as a quiz question?MATLAB Grader can be integrated into Moodle as an external tool. How can you use MATLAB Grader in Moodle Quizzes, to implement MATLAB Grader as a quiz question? MATLAB Grader can be integrated into Moodle as an external tool. How can you use MATLAB Grader in Moodle Quizzes, to implement MATLAB Grader as a quiz question? distance_learning, moodle, matlab grader MATLAB Answers — New Questions
How to use all cores for running a Simulink model?
Hi,
I modeled a thermal-fluid network in Simulink with Simscape modules and I want to use all cores in order to speed up my simulation.
I am using a workstation with 64 physical cores and 128 logical cores, but I get the same run-time as when I run the model on my Laptop with 6 physical cores and 12 logical cores. What should I do that Simulink uses all the capacity of my workstation for running a model?
I would appreciate if you could help me.Hi,
I modeled a thermal-fluid network in Simulink with Simscape modules and I want to use all cores in order to speed up my simulation.
I am using a workstation with 64 physical cores and 128 logical cores, but I get the same run-time as when I run the model on my Laptop with 6 physical cores and 12 logical cores. What should I do that Simulink uses all the capacity of my workstation for running a model?
I would appreciate if you could help me. Hi,
I modeled a thermal-fluid network in Simulink with Simscape modules and I want to use all cores in order to speed up my simulation.
I am using a workstation with 64 physical cores and 128 logical cores, but I get the same run-time as when I run the model on my Laptop with 6 physical cores and 12 logical cores. What should I do that Simulink uses all the capacity of my workstation for running a model?
I would appreciate if you could help me. parallel computing in simulink MATLAB Answers — New Questions
Trend Micro’s security software prevents MATLAB’s access to “MATLABWindow.exe” file, inhibiting web-based applications from running.
Why am I unable to use web-based applications such as Simulink, App Designer, Simscape, etc.?Why am I unable to use web-based applications such as Simulink, App Designer, Simscape, etc.? Why am I unable to use web-based applications such as Simulink, App Designer, Simscape, etc.? trendmicro, antivirus, exit, code, 1073741819, matlab.internal.cef.webwindow MATLAB Answers — New Questions
Accessing parameters in encrypted models
I have an encrypted Simulink model with some tunable parameters. I can change them by right-clicking on the model and choosing ‘Block Parameters (ModelReference)’. However, unlike other (nonencrypted) blocks, I can’t change them by using ‘set_param’. Is there any way of accessing these parameters from the command line? I’m using Simulink R2015b.I have an encrypted Simulink model with some tunable parameters. I can change them by right-clicking on the model and choosing ‘Block Parameters (ModelReference)’. However, unlike other (nonencrypted) blocks, I can’t change them by using ‘set_param’. Is there any way of accessing these parameters from the command line? I’m using Simulink R2015b. I have an encrypted Simulink model with some tunable parameters. I can change them by right-clicking on the model and choosing ‘Block Parameters (ModelReference)’. However, unlike other (nonencrypted) blocks, I can’t change them by using ‘set_param’. Is there any way of accessing these parameters from the command line? I’m using Simulink R2015b. encrypted model, parameters, set_param MATLAB Answers — New Questions
App designer generated app freezes in function “createComponents(app)”
Hi
I’ve written an application using App Designer with 100s of components. When I start the app it freezes during the build of the components in the App Designer generated function createComponents. This happens before my own code starts to execute. The way to avoid this freeze is to add a breakpont far down in the createComponents function. createComponents is called before registerApp and runStartupFcn is called. All the mentioned functions are generated before my own code start to execute and are generated by App Designer and are therefore grayed out which means I can’t do any edits.
Is this freeze problem known to this community and is there a fix for this?
Is there any way for me to edit the App Designer generated functions? I would like to add a pause instead of a breakpoint as a possible way to solve the freeze in createComponents function…
I’m running Matlab R2022a Update 8.
Most grateful for your hints and tipsHi
I’ve written an application using App Designer with 100s of components. When I start the app it freezes during the build of the components in the App Designer generated function createComponents. This happens before my own code starts to execute. The way to avoid this freeze is to add a breakpont far down in the createComponents function. createComponents is called before registerApp and runStartupFcn is called. All the mentioned functions are generated before my own code start to execute and are generated by App Designer and are therefore grayed out which means I can’t do any edits.
Is this freeze problem known to this community and is there a fix for this?
Is there any way for me to edit the App Designer generated functions? I would like to add a pause instead of a breakpoint as a possible way to solve the freeze in createComponents function…
I’m running Matlab R2022a Update 8.
Most grateful for your hints and tips Hi
I’ve written an application using App Designer with 100s of components. When I start the app it freezes during the build of the components in the App Designer generated function createComponents. This happens before my own code starts to execute. The way to avoid this freeze is to add a breakpont far down in the createComponents function. createComponents is called before registerApp and runStartupFcn is called. All the mentioned functions are generated before my own code start to execute and are generated by App Designer and are therefore grayed out which means I can’t do any edits.
Is this freeze problem known to this community and is there a fix for this?
Is there any way for me to edit the App Designer generated functions? I would like to add a pause instead of a breakpoint as a possible way to solve the freeze in createComponents function…
I’m running Matlab R2022a Update 8.
Most grateful for your hints and tips appdesigner, createcomponents MATLAB Answers — New Questions
Fit data to lagged custom function
Hello,
I would like to ask if you can advice the correct approach I can follow to estimate the parameters of a custom lagged function
(1) y(t)=c^2*a+y(t-1)*(a-1)
where c is a known constant.
to a time series data (I can use the symbilic function to create (1) )
Thank you.
Best regards
PaoloHello,
I would like to ask if you can advice the correct approach I can follow to estimate the parameters of a custom lagged function
(1) y(t)=c^2*a+y(t-1)*(a-1)
where c is a known constant.
to a time series data (I can use the symbilic function to create (1) )
Thank you.
Best regards
Paolo Hello,
I would like to ask if you can advice the correct approach I can follow to estimate the parameters of a custom lagged function
(1) y(t)=c^2*a+y(t-1)*(a-1)
where c is a known constant.
to a time series data (I can use the symbilic function to create (1) )
Thank you.
Best regards
Paolo curve fitting, time series MATLAB Answers — New Questions
Simulink mask: show/hide the port of a custom Simulink block
Hi guys,
I am creating a mask for my custom block and I want add a checkbox with the following behaviour:
checked: it shows a new port the the block
unhecked: it hides the new port for the block
The integrator block has the same behaviour (see the belows images to understand):
I am struggling how to implement this feature in the Checkbox callback because I can’t find the parameter to show/hide the port.Hi guys,
I am creating a mask for my custom block and I want add a checkbox with the following behaviour:
checked: it shows a new port the the block
unhecked: it hides the new port for the block
The integrator block has the same behaviour (see the belows images to understand):
I am struggling how to implement this feature in the Checkbox callback because I can’t find the parameter to show/hide the port. Hi guys,
I am creating a mask for my custom block and I want add a checkbox with the following behaviour:
checked: it shows a new port the the block
unhecked: it hides the new port for the block
The integrator block has the same behaviour (see the belows images to understand):
I am struggling how to implement this feature in the Checkbox callback because I can’t find the parameter to show/hide the port. simulink, mask, integrator, custom MATLAB Answers — New Questions
Compilation Error encountered while running Polyspace Bug Finder.
Version : R2021a
language : C
C version : C11
Compiler : ti
Target : C28x
Project : TMS320F28374s
Error :
—
File D:CCS_workspacePolyspace testPatriotSafetyMonitor_SL1_SL2_20240710_058.000_Gen3C2000_18_12_2_LTS_Includestdlib.h line 294
Error: declaration is incompatible with "long __euclidean_div_i32byu32(long, unsigned long, unsigned long)" (declared at line 50 of "C:Program FilesPolyspaceR2021apolyspaceverifierextensionstitmw_builtinsc28x.h")
__euclidean_div_i32byu32(long numerator, unsigned long denominator);
^
When performing Bug Finder analysis, an incompatibility occurs between Polyspace’s C28x.h and my .h file. However, the same program does not exhibit these issues on some computers. I hope to identify the true cause to ensure the program is error-free. Could you please explain the role of C28x.h in the analysis? Additionally, is it reasonable to modify C28x.h?Version : R2021a
language : C
C version : C11
Compiler : ti
Target : C28x
Project : TMS320F28374s
Error :
—
File D:CCS_workspacePolyspace testPatriotSafetyMonitor_SL1_SL2_20240710_058.000_Gen3C2000_18_12_2_LTS_Includestdlib.h line 294
Error: declaration is incompatible with "long __euclidean_div_i32byu32(long, unsigned long, unsigned long)" (declared at line 50 of "C:Program FilesPolyspaceR2021apolyspaceverifierextensionstitmw_builtinsc28x.h")
__euclidean_div_i32byu32(long numerator, unsigned long denominator);
^
When performing Bug Finder analysis, an incompatibility occurs between Polyspace’s C28x.h and my .h file. However, the same program does not exhibit these issues on some computers. I hope to identify the true cause to ensure the program is error-free. Could you please explain the role of C28x.h in the analysis? Additionally, is it reasonable to modify C28x.h? Version : R2021a
language : C
C version : C11
Compiler : ti
Target : C28x
Project : TMS320F28374s
Error :
—
File D:CCS_workspacePolyspace testPatriotSafetyMonitor_SL1_SL2_20240710_058.000_Gen3C2000_18_12_2_LTS_Includestdlib.h line 294
Error: declaration is incompatible with "long __euclidean_div_i32byu32(long, unsigned long, unsigned long)" (declared at line 50 of "C:Program FilesPolyspaceR2021apolyspaceverifierextensionstitmw_builtinsc28x.h")
__euclidean_div_i32byu32(long numerator, unsigned long denominator);
^
When performing Bug Finder analysis, an incompatibility occurs between Polyspace’s C28x.h and my .h file. However, the same program does not exhibit these issues on some computers. I hope to identify the true cause to ensure the program is error-free. Could you please explain the role of C28x.h in the analysis? Additionally, is it reasonable to modify C28x.h? polyspace, bug finder MATLAB Answers — New Questions
Effect size, statistical power of the test, and confidence interval (of hypothesis testing)
I am using the following two-sample tests for non-normal distributions:
chi2gof
kstest2
ranksum
kruskalwallis
All of them return a p-value, i.e. a p-value for chi2gof, a p-value for kstest2, a p-value for ranksum, and a p-value for kruskalwallis.
Since the p-value is not enough to understand the data/distributions (for example, please see Sullivan & Feinn (2012), Dunkler et al.(2020), Greenland (2016), and du Prel et al. (2009)), I would like to calculate the effect size, the statistical power of the test, and the confidence interval (of hypothesis testing).
I would use the following MATLAB functions:
meanEffectSize (two-sample effect size computations)
sampsizepwr (power of the test)
not found anything about the confidence interval..
However:
I am not sure if both functions, meanEffectSize and sampsizepwr, can be "compatible" with (i) non-normal distributions and (ii) with the 4 previously mentioned tests.
According to the documentation I found on sampsizepwr, it looks like that the calculation of the statistical power of the test works only with normal distributions, but I am not sure.
Those 4 mentioned tests do not provide the confidence interval. Maybe other MATLAB function do, but I was not able to find them.
I have then 2 questions:
Question 1. Is there anyone who could kindly enlighten me on the "compatibility" of meanEffectSize and sampsizepw with with (i) non-normal distributions and (ii) with the 4 previously mentioned tests?
Question 2. Is there anyone who could kindly tell me if there are MATLAB functions to calculate the confidence intervals for the 4 mentioned statistical tests?I am using the following two-sample tests for non-normal distributions:
chi2gof
kstest2
ranksum
kruskalwallis
All of them return a p-value, i.e. a p-value for chi2gof, a p-value for kstest2, a p-value for ranksum, and a p-value for kruskalwallis.
Since the p-value is not enough to understand the data/distributions (for example, please see Sullivan & Feinn (2012), Dunkler et al.(2020), Greenland (2016), and du Prel et al. (2009)), I would like to calculate the effect size, the statistical power of the test, and the confidence interval (of hypothesis testing).
I would use the following MATLAB functions:
meanEffectSize (two-sample effect size computations)
sampsizepwr (power of the test)
not found anything about the confidence interval..
However:
I am not sure if both functions, meanEffectSize and sampsizepwr, can be "compatible" with (i) non-normal distributions and (ii) with the 4 previously mentioned tests.
According to the documentation I found on sampsizepwr, it looks like that the calculation of the statistical power of the test works only with normal distributions, but I am not sure.
Those 4 mentioned tests do not provide the confidence interval. Maybe other MATLAB function do, but I was not able to find them.
I have then 2 questions:
Question 1. Is there anyone who could kindly enlighten me on the "compatibility" of meanEffectSize and sampsizepw with with (i) non-normal distributions and (ii) with the 4 previously mentioned tests?
Question 2. Is there anyone who could kindly tell me if there are MATLAB functions to calculate the confidence intervals for the 4 mentioned statistical tests? I am using the following two-sample tests for non-normal distributions:
chi2gof
kstest2
ranksum
kruskalwallis
All of them return a p-value, i.e. a p-value for chi2gof, a p-value for kstest2, a p-value for ranksum, and a p-value for kruskalwallis.
Since the p-value is not enough to understand the data/distributions (for example, please see Sullivan & Feinn (2012), Dunkler et al.(2020), Greenland (2016), and du Prel et al. (2009)), I would like to calculate the effect size, the statistical power of the test, and the confidence interval (of hypothesis testing).
I would use the following MATLAB functions:
meanEffectSize (two-sample effect size computations)
sampsizepwr (power of the test)
not found anything about the confidence interval..
However:
I am not sure if both functions, meanEffectSize and sampsizepwr, can be "compatible" with (i) non-normal distributions and (ii) with the 4 previously mentioned tests.
According to the documentation I found on sampsizepwr, it looks like that the calculation of the statistical power of the test works only with normal distributions, but I am not sure.
Those 4 mentioned tests do not provide the confidence interval. Maybe other MATLAB function do, but I was not able to find them.
I have then 2 questions:
Question 1. Is there anyone who could kindly enlighten me on the "compatibility" of meanEffectSize and sampsizepw with with (i) non-normal distributions and (ii) with the 4 previously mentioned tests?
Question 2. Is there anyone who could kindly tell me if there are MATLAB functions to calculate the confidence intervals for the 4 mentioned statistical tests? effect size, statistical power, confidence interval, chi2gof, kstest2, ranksum, kruskalwallis MATLAB Answers — New Questions
Tuning ExperienceHorizon hyperparamter for PPO agent (Reinforcement Learning)
Hello everyone,
I’m trying to train a PPO agent, and I would like to change the value for the ExperienceHorizon hyperparameter (Options for PPO agent – MATLAB – MathWorks Switzerland)
When I try another value than the default, the agent wait for the end of the episode to update its policy. For example, ExperienceHorizon=1024 don’t work for me, dispite the episode’s lenght of more than 1024 steps. I’m also not using Parallel training.
I also get the same issue if I change the MiniBatchSize from its default value.
Is there anything I’ve missed about this parameter?
More infos on PPO algorithms: Proximal Policy Optimization (PPO) Agents – MATLAB & Simulink – MathWorks Switzerland
If anyone could help, that would be very nice!
Thanks a lot in advance,
NicolasHello everyone,
I’m trying to train a PPO agent, and I would like to change the value for the ExperienceHorizon hyperparameter (Options for PPO agent – MATLAB – MathWorks Switzerland)
When I try another value than the default, the agent wait for the end of the episode to update its policy. For example, ExperienceHorizon=1024 don’t work for me, dispite the episode’s lenght of more than 1024 steps. I’m also not using Parallel training.
I also get the same issue if I change the MiniBatchSize from its default value.
Is there anything I’ve missed about this parameter?
More infos on PPO algorithms: Proximal Policy Optimization (PPO) Agents – MATLAB & Simulink – MathWorks Switzerland
If anyone could help, that would be very nice!
Thanks a lot in advance,
Nicolas Hello everyone,
I’m trying to train a PPO agent, and I would like to change the value for the ExperienceHorizon hyperparameter (Options for PPO agent – MATLAB – MathWorks Switzerland)
When I try another value than the default, the agent wait for the end of the episode to update its policy. For example, ExperienceHorizon=1024 don’t work for me, dispite the episode’s lenght of more than 1024 steps. I’m also not using Parallel training.
I also get the same issue if I change the MiniBatchSize from its default value.
Is there anything I’ve missed about this parameter?
More infos on PPO algorithms: Proximal Policy Optimization (PPO) Agents – MATLAB & Simulink – MathWorks Switzerland
If anyone could help, that would be very nice!
Thanks a lot in advance,
Nicolas ppo agents, reinforcement learning, experience horizon MATLAB Answers — New Questions
is it possible to see what variables and functions affecting a certain variable ?
hello everyone,
i am having a little problem, i need to figure out what affects one variable. that variable is in a for loop, which is in a function, which is also in a function and several values are also calculated by several other functions…
i do know i can have a chart what functions are involved and how they are affect each other, when i have a project. however, i cant see the variables there, or if i dont know how.
so thats my question, how can i see the functions AND variables that affect one variable.hello everyone,
i am having a little problem, i need to figure out what affects one variable. that variable is in a for loop, which is in a function, which is also in a function and several values are also calculated by several other functions…
i do know i can have a chart what functions are involved and how they are affect each other, when i have a project. however, i cant see the variables there, or if i dont know how.
so thats my question, how can i see the functions AND variables that affect one variable. hello everyone,
i am having a little problem, i need to figure out what affects one variable. that variable is in a for loop, which is in a function, which is also in a function and several values are also calculated by several other functions…
i do know i can have a chart what functions are involved and how they are affect each other, when i have a project. however, i cant see the variables there, or if i dont know how.
so thats my question, how can i see the functions AND variables that affect one variable. variable, function MATLAB Answers — New Questions
lung segmentation in MR-Dataset
Hello,
does anybody know a way to segment Lungs from mri-dataset? I foud many ways to segment them in CT, but not in MR.
I tried the otsu and the k-means methods, but the heart is alway segmented with the lungsHello,
does anybody know a way to segment Lungs from mri-dataset? I foud many ways to segment them in CT, but not in MR.
I tried the otsu and the k-means methods, but the heart is alway segmented with the lungs Hello,
does anybody know a way to segment Lungs from mri-dataset? I foud many ways to segment them in CT, but not in MR.
I tried the otsu and the k-means methods, but the heart is alway segmented with the lungs image segmentation, image processing, lung, mri MATLAB Answers — New Questions
error about MATLAB Runtime 7.5 download
I want to download the MATLAB Runtime (MCR) 7.5 version.
However, when I run the .exe file, I get the following warning.
"Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support or package vendor"
Is there a solution to this?I want to download the MATLAB Runtime (MCR) 7.5 version.
However, when I run the .exe file, I get the following warning.
"Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support or package vendor"
Is there a solution to this? I want to download the MATLAB Runtime (MCR) 7.5 version.
However, when I run the .exe file, I get the following warning.
"Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support or package vendor"
Is there a solution to this? mcr MATLAB Answers — New Questions
How to use modern features (notably std::unique_ptr) in the C++ code of my S-functions while using the linaro v4.8 toolchain in embedded coder?
Background
I am using simulink with S-functions containing custom C++ code. My simulink model runs on an ARM board running Linux, using embedded coder. My C++ code uses unique pointers (std::unique_ptr). The toolchain I use is Linaro v4.8.
The error
I get the following error when building the Linux executable using the simulink ‘build’ button:
C:/my_path/cpp/src/my_class.h:13:5: error: ‘unique_ptr’ in namespace ‘std’ does not name a type
My idea
I suspect that the C++ version being compiled to is < c++11, and I would like to force the g++ compiler to compile the code using c++11. I can’t change compiler flags in the simulink menu, it is grayed out.
I found the linaro toolchain xml file and changed compiler flags there, but when I look at the compiler command generated in simulink I do not see the -std=c++11 compiler flag anywhere.
The question
How can I use modern features (notably std::unique_ptr) in the C++ code of my S-functions while using the linaro v4.8 toolchain in simulink embedded coder?Background
I am using simulink with S-functions containing custom C++ code. My simulink model runs on an ARM board running Linux, using embedded coder. My C++ code uses unique pointers (std::unique_ptr). The toolchain I use is Linaro v4.8.
The error
I get the following error when building the Linux executable using the simulink ‘build’ button:
C:/my_path/cpp/src/my_class.h:13:5: error: ‘unique_ptr’ in namespace ‘std’ does not name a type
My idea
I suspect that the C++ version being compiled to is < c++11, and I would like to force the g++ compiler to compile the code using c++11. I can’t change compiler flags in the simulink menu, it is grayed out.
I found the linaro toolchain xml file and changed compiler flags there, but when I look at the compiler command generated in simulink I do not see the -std=c++11 compiler flag anywhere.
The question
How can I use modern features (notably std::unique_ptr) in the C++ code of my S-functions while using the linaro v4.8 toolchain in simulink embedded coder? Background
I am using simulink with S-functions containing custom C++ code. My simulink model runs on an ARM board running Linux, using embedded coder. My C++ code uses unique pointers (std::unique_ptr). The toolchain I use is Linaro v4.8.
The error
I get the following error when building the Linux executable using the simulink ‘build’ button:
C:/my_path/cpp/src/my_class.h:13:5: error: ‘unique_ptr’ in namespace ‘std’ does not name a type
My idea
I suspect that the C++ version being compiled to is < c++11, and I would like to force the g++ compiler to compile the code using c++11. I can’t change compiler flags in the simulink menu, it is grayed out.
I found the linaro toolchain xml file and changed compiler flags there, but when I look at the compiler command generated in simulink I do not see the -std=c++11 compiler flag anywhere.
The question
How can I use modern features (notably std::unique_ptr) in the C++ code of my S-functions while using the linaro v4.8 toolchain in simulink embedded coder? embedded coder, s-function, simulink, linux MATLAB Answers — New Questions
copping grayscale image and remove any other borders or details
could you please help me to get only the gray scale images without any borders and without any written words or letters created by the device . i want a general code to do this beause i have other images with other border thickness and other written , and i want the gray image entire only
@Image Analyst
Image Analystcould you please help me to get only the gray scale images without any borders and without any written words or letters created by the device . i want a general code to do this beause i have other images with other border thickness and other written , and i want the gray image entire only
@Image Analyst
Image Analyst could you please help me to get only the gray scale images without any borders and without any written words or letters created by the device . i want a general code to do this beause i have other images with other border thickness and other written , and i want the gray image entire only
@Image Analyst
Image Analyst image analyst MATLAB Answers — New Questions
Design a feedback controller to control pH value of a non linear system
Hi all!.
I am working on a question where we calculate an optimal dosage using multiple sensor inputs. Then we send the calculated dosage to the plant and we monitor the pH value. Right now we have an open loop system. I want to maintain the output pH value in a range of 5.2 to 5.8 by introducing a feedback and a PID controller.
I have previous data about the dosage we calculated and the resulted pH values.Hi all!.
I am working on a question where we calculate an optimal dosage using multiple sensor inputs. Then we send the calculated dosage to the plant and we monitor the pH value. Right now we have an open loop system. I want to maintain the output pH value in a range of 5.2 to 5.8 by introducing a feedback and a PID controller.
I have previous data about the dosage we calculated and the resulted pH values. Hi all!.
I am working on a question where we calculate an optimal dosage using multiple sensor inputs. Then we send the calculated dosage to the plant and we monitor the pH value. Right now we have an open loop system. I want to maintain the output pH value in a range of 5.2 to 5.8 by introducing a feedback and a PID controller.
I have previous data about the dosage we calculated and the resulted pH values. pid, ph, feedback control MATLAB Answers — New Questions
wt is the Activation Key for activating MATLAB Simulink
Activation KeyActivation Key Activation Key provide activation key for matlab MATLAB Answers — New Questions
vgg16 not installed as Deep learning toolbox has missing this package
Error using vgg16 (line 60)
vgg16 requires the Deep Learning Toolbox Model for VGG-16 Network support package. To install this support package, use the Add-On Explorer.
How can we run the program without package installed? Is there any solution?Error using vgg16 (line 60)
vgg16 requires the Deep Learning Toolbox Model for VGG-16 Network support package. To install this support package, use the Add-On Explorer.
How can we run the program without package installed? Is there any solution? Error using vgg16 (line 60)
vgg16 requires the Deep Learning Toolbox Model for VGG-16 Network support package. To install this support package, use the Add-On Explorer.
How can we run the program without package installed? Is there any solution? neural network model, vgg16 MATLAB Answers — New Questions
Using FFT Coefficients/Descriptors to reconstruct particle shape
Hi, I am trying to use Fourier descriptors to reconstruct the shape of a particle. I have written most of the code (with a lot of help) and only the last step which involves using Fourier descriptors to reconstruct the shape of the original image remains.
I need help to know which functions to use to achieve this. I would really appreciate if anyone could help.
Here is the code:
I have also attached the original image and another file which demonstrates what I need to do.
scale_factor = 100/90; % (units: microns/pixel)
% to convert pixels to microns,
% multiply # of pixels by scale_factor
%1. Open and show image of particle
img = imread(‘1_50.JPG’); %Read image
subplot (3,3,1)
imshow(img) %show image
%2. Binarize and show image
BW = im2bw(img,0.45); %binarize image with a threshold value of 0.45
img1= bwareaopen (BW, 1000); %Remove small objects
img2= imfill(img1, ‘holes’); %fill holes
subplot(3,3,2)
imshow(img2) %show binarized image
%3. Setting up the axes
% for plotting into multiple axes in one loop, it’s convenient to set up
% all the axes first, before anything is plotted into them
% 3.1. set up the 2nd axes:
ax3 = subplot(3,3,3);
hold on
box on %draws a box that encompasses the entire axes area
axis image %sets the aspect ratio of the axes (ax2) to be equal and
%adjusts the limits of the axes so that the data units are
%of equal size along both the x-axis and y-axis.
set(ax3,’YDir’,’reverse’) %reverses the y-axis to begin from the top
%since the origin of the image is at the top left-corner
% 3.2. set up the 3rd axes:
ax4 = subplot(3,3,4);
hold on
%4. Compute centroid of binarized image
centriod_value= regionprops(img2, ‘Centroid’); %Finds centroid of image
centroid = cat(1,centriod_value.Centroid); %Stores centroid coordinates in a two-column matrix
%5. Tracing the boundary of image
p_boundary= bwboundaries(img2); % trace the exterior boundaries of particle
%(in row, column order, not x,y)
number_of_boundaries = size(p_boundary,1); %specify only one boundary
centroid = centroid*scale_factor;
% 6. Setting up equally spaced angles before initing the loop
%use 129 points to have an angle spacing of 360/128
N_angles = 129;
interp_angles = linspace(0,360,N_angles).’;
%7. Initiate for loop to plot boundary, centroid, & a graph of radius vs angle
for k = 1 : number_of_boundaries % initiate loop to go round the selected boundary
thisBoundary = p_boundary{k}*scale_factor;
y = thisBoundary(:,1); % rows
x = thisBoundary(:,2); % columns
plot(ax3, x, y, ‘g’, ‘LineWidth’, 2);
plot(ax3, centroid(:,1),centroid(:,2),’b.’)
% 7.1. Calculate the angles in degrees
deltaY = thisBoundary(:,1) – centroid(k,2); % boundary(:,1) is y, but centroid(k,2) is y
deltaX = thisBoundary(:,2) – centroid(k,1); % boundary(:,2) is x, but centroid(k,1) is x
% angles = atand(deltaY ./ deltaX); % atand gives angles in range [-90,90]
angles = atan2d(deltaY,deltaX); % use atan2d to get angles in range [-180,180]
% 7.2. Calculate the radii
radius = sqrt(deltaY.^2 + deltaX.^2); % use deltaX and deltaY, which were just calculated
% 7.3. Add 360 degrees to negative angles so that range is [0,360] instead of [-180,180]
idx = angles < 0; %idx reps angles less than 0 degreees
angles(idx) = angles(idx)+360; %360 degrees is added to idx angles
%7.4. Sort angles in ascending order
% sort the angles, so the first one is smallest (closest to zero)
% and the last one is largest (closest to 360)
% this is useful for getting a smooth line that goes from 0 to 360 in the plot
% I returns the corresponding indices of the angles
[angles,I] = sort(angles);
%7.5. Reorder distances the same way angles was reordered using I
radius = radius(I);
%7.6. Use only unique angles in case an angle is repeated
% in case any angles are repeated, use only the unique set and
% corresponding distances in interp1 (in this data, one angle is
% repeated twice, with the same distance each time)
%The ~ (tilde) here is a placeholder indicating that we’re not interested
%in capturing the actual unique elements, only their indices
[~,I] = unique(angles);
% 7.7. perform linear interpolation/extrapolation:
%angles(I)= sample points, radius(I)= correspoinding points
%and interp_angles = coordinates of the querry points (QP)
%In general, the functions returns interpolated values at specific QP
interp_distances = interp1(angles(I),radius(I),interp_angles,’linear’,’extrap’);
% 7.8 Plot distance vs. angle.
plot(ax4,interp_angles,interp_distances)
end
%8. Apply fft algorithm to values of radius
L = length(interp_distances); %Define the number of the radiuses (points)
f = 0:L-1; %Define the sampling frequencies
A = fft(interp_distances); %Transforming the radius function into frequency domain using FFT
B = (abs(A)/2535.2); % Normalize the amplitude of fourier descriptors using the first descriptors
%9. Plot fft descriptor vs. frequency
subplot(3,3,5)
bar(f,B,3) %plot the frequencies vs. the nornalised descriptors
xlim([0 128])
%10. Plot phase angle vs. frequency
subplot(3,3,6)
bar(f, angle(A),3) % plot the frequencies vs phase angles
xlim([0 128])
ylim([-4 4])
%11. Create a table of values
table1 = table(A, f’, abs(A), B, angle(A));
table1.Properties.VariableNames = {‘FFT_coeffs’, ‘Frequency’, ‘Amplitude’, ‘Norm_Amplitude’ ‘Phase’};
disp(table1);
%12. Reconstruct particle boundary using FFT descriptors ?????Hi, I am trying to use Fourier descriptors to reconstruct the shape of a particle. I have written most of the code (with a lot of help) and only the last step which involves using Fourier descriptors to reconstruct the shape of the original image remains.
I need help to know which functions to use to achieve this. I would really appreciate if anyone could help.
Here is the code:
I have also attached the original image and another file which demonstrates what I need to do.
scale_factor = 100/90; % (units: microns/pixel)
% to convert pixels to microns,
% multiply # of pixels by scale_factor
%1. Open and show image of particle
img = imread(‘1_50.JPG’); %Read image
subplot (3,3,1)
imshow(img) %show image
%2. Binarize and show image
BW = im2bw(img,0.45); %binarize image with a threshold value of 0.45
img1= bwareaopen (BW, 1000); %Remove small objects
img2= imfill(img1, ‘holes’); %fill holes
subplot(3,3,2)
imshow(img2) %show binarized image
%3. Setting up the axes
% for plotting into multiple axes in one loop, it’s convenient to set up
% all the axes first, before anything is plotted into them
% 3.1. set up the 2nd axes:
ax3 = subplot(3,3,3);
hold on
box on %draws a box that encompasses the entire axes area
axis image %sets the aspect ratio of the axes (ax2) to be equal and
%adjusts the limits of the axes so that the data units are
%of equal size along both the x-axis and y-axis.
set(ax3,’YDir’,’reverse’) %reverses the y-axis to begin from the top
%since the origin of the image is at the top left-corner
% 3.2. set up the 3rd axes:
ax4 = subplot(3,3,4);
hold on
%4. Compute centroid of binarized image
centriod_value= regionprops(img2, ‘Centroid’); %Finds centroid of image
centroid = cat(1,centriod_value.Centroid); %Stores centroid coordinates in a two-column matrix
%5. Tracing the boundary of image
p_boundary= bwboundaries(img2); % trace the exterior boundaries of particle
%(in row, column order, not x,y)
number_of_boundaries = size(p_boundary,1); %specify only one boundary
centroid = centroid*scale_factor;
% 6. Setting up equally spaced angles before initing the loop
%use 129 points to have an angle spacing of 360/128
N_angles = 129;
interp_angles = linspace(0,360,N_angles).’;
%7. Initiate for loop to plot boundary, centroid, & a graph of radius vs angle
for k = 1 : number_of_boundaries % initiate loop to go round the selected boundary
thisBoundary = p_boundary{k}*scale_factor;
y = thisBoundary(:,1); % rows
x = thisBoundary(:,2); % columns
plot(ax3, x, y, ‘g’, ‘LineWidth’, 2);
plot(ax3, centroid(:,1),centroid(:,2),’b.’)
% 7.1. Calculate the angles in degrees
deltaY = thisBoundary(:,1) – centroid(k,2); % boundary(:,1) is y, but centroid(k,2) is y
deltaX = thisBoundary(:,2) – centroid(k,1); % boundary(:,2) is x, but centroid(k,1) is x
% angles = atand(deltaY ./ deltaX); % atand gives angles in range [-90,90]
angles = atan2d(deltaY,deltaX); % use atan2d to get angles in range [-180,180]
% 7.2. Calculate the radii
radius = sqrt(deltaY.^2 + deltaX.^2); % use deltaX and deltaY, which were just calculated
% 7.3. Add 360 degrees to negative angles so that range is [0,360] instead of [-180,180]
idx = angles < 0; %idx reps angles less than 0 degreees
angles(idx) = angles(idx)+360; %360 degrees is added to idx angles
%7.4. Sort angles in ascending order
% sort the angles, so the first one is smallest (closest to zero)
% and the last one is largest (closest to 360)
% this is useful for getting a smooth line that goes from 0 to 360 in the plot
% I returns the corresponding indices of the angles
[angles,I] = sort(angles);
%7.5. Reorder distances the same way angles was reordered using I
radius = radius(I);
%7.6. Use only unique angles in case an angle is repeated
% in case any angles are repeated, use only the unique set and
% corresponding distances in interp1 (in this data, one angle is
% repeated twice, with the same distance each time)
%The ~ (tilde) here is a placeholder indicating that we’re not interested
%in capturing the actual unique elements, only their indices
[~,I] = unique(angles);
% 7.7. perform linear interpolation/extrapolation:
%angles(I)= sample points, radius(I)= correspoinding points
%and interp_angles = coordinates of the querry points (QP)
%In general, the functions returns interpolated values at specific QP
interp_distances = interp1(angles(I),radius(I),interp_angles,’linear’,’extrap’);
% 7.8 Plot distance vs. angle.
plot(ax4,interp_angles,interp_distances)
end
%8. Apply fft algorithm to values of radius
L = length(interp_distances); %Define the number of the radiuses (points)
f = 0:L-1; %Define the sampling frequencies
A = fft(interp_distances); %Transforming the radius function into frequency domain using FFT
B = (abs(A)/2535.2); % Normalize the amplitude of fourier descriptors using the first descriptors
%9. Plot fft descriptor vs. frequency
subplot(3,3,5)
bar(f,B,3) %plot the frequencies vs. the nornalised descriptors
xlim([0 128])
%10. Plot phase angle vs. frequency
subplot(3,3,6)
bar(f, angle(A),3) % plot the frequencies vs phase angles
xlim([0 128])
ylim([-4 4])
%11. Create a table of values
table1 = table(A, f’, abs(A), B, angle(A));
table1.Properties.VariableNames = {‘FFT_coeffs’, ‘Frequency’, ‘Amplitude’, ‘Norm_Amplitude’ ‘Phase’};
disp(table1);
%12. Reconstruct particle boundary using FFT descriptors ????? Hi, I am trying to use Fourier descriptors to reconstruct the shape of a particle. I have written most of the code (with a lot of help) and only the last step which involves using Fourier descriptors to reconstruct the shape of the original image remains.
I need help to know which functions to use to achieve this. I would really appreciate if anyone could help.
Here is the code:
I have also attached the original image and another file which demonstrates what I need to do.
scale_factor = 100/90; % (units: microns/pixel)
% to convert pixels to microns,
% multiply # of pixels by scale_factor
%1. Open and show image of particle
img = imread(‘1_50.JPG’); %Read image
subplot (3,3,1)
imshow(img) %show image
%2. Binarize and show image
BW = im2bw(img,0.45); %binarize image with a threshold value of 0.45
img1= bwareaopen (BW, 1000); %Remove small objects
img2= imfill(img1, ‘holes’); %fill holes
subplot(3,3,2)
imshow(img2) %show binarized image
%3. Setting up the axes
% for plotting into multiple axes in one loop, it’s convenient to set up
% all the axes first, before anything is plotted into them
% 3.1. set up the 2nd axes:
ax3 = subplot(3,3,3);
hold on
box on %draws a box that encompasses the entire axes area
axis image %sets the aspect ratio of the axes (ax2) to be equal and
%adjusts the limits of the axes so that the data units are
%of equal size along both the x-axis and y-axis.
set(ax3,’YDir’,’reverse’) %reverses the y-axis to begin from the top
%since the origin of the image is at the top left-corner
% 3.2. set up the 3rd axes:
ax4 = subplot(3,3,4);
hold on
%4. Compute centroid of binarized image
centriod_value= regionprops(img2, ‘Centroid’); %Finds centroid of image
centroid = cat(1,centriod_value.Centroid); %Stores centroid coordinates in a two-column matrix
%5. Tracing the boundary of image
p_boundary= bwboundaries(img2); % trace the exterior boundaries of particle
%(in row, column order, not x,y)
number_of_boundaries = size(p_boundary,1); %specify only one boundary
centroid = centroid*scale_factor;
% 6. Setting up equally spaced angles before initing the loop
%use 129 points to have an angle spacing of 360/128
N_angles = 129;
interp_angles = linspace(0,360,N_angles).’;
%7. Initiate for loop to plot boundary, centroid, & a graph of radius vs angle
for k = 1 : number_of_boundaries % initiate loop to go round the selected boundary
thisBoundary = p_boundary{k}*scale_factor;
y = thisBoundary(:,1); % rows
x = thisBoundary(:,2); % columns
plot(ax3, x, y, ‘g’, ‘LineWidth’, 2);
plot(ax3, centroid(:,1),centroid(:,2),’b.’)
% 7.1. Calculate the angles in degrees
deltaY = thisBoundary(:,1) – centroid(k,2); % boundary(:,1) is y, but centroid(k,2) is y
deltaX = thisBoundary(:,2) – centroid(k,1); % boundary(:,2) is x, but centroid(k,1) is x
% angles = atand(deltaY ./ deltaX); % atand gives angles in range [-90,90]
angles = atan2d(deltaY,deltaX); % use atan2d to get angles in range [-180,180]
% 7.2. Calculate the radii
radius = sqrt(deltaY.^2 + deltaX.^2); % use deltaX and deltaY, which were just calculated
% 7.3. Add 360 degrees to negative angles so that range is [0,360] instead of [-180,180]
idx = angles < 0; %idx reps angles less than 0 degreees
angles(idx) = angles(idx)+360; %360 degrees is added to idx angles
%7.4. Sort angles in ascending order
% sort the angles, so the first one is smallest (closest to zero)
% and the last one is largest (closest to 360)
% this is useful for getting a smooth line that goes from 0 to 360 in the plot
% I returns the corresponding indices of the angles
[angles,I] = sort(angles);
%7.5. Reorder distances the same way angles was reordered using I
radius = radius(I);
%7.6. Use only unique angles in case an angle is repeated
% in case any angles are repeated, use only the unique set and
% corresponding distances in interp1 (in this data, one angle is
% repeated twice, with the same distance each time)
%The ~ (tilde) here is a placeholder indicating that we’re not interested
%in capturing the actual unique elements, only their indices
[~,I] = unique(angles);
% 7.7. perform linear interpolation/extrapolation:
%angles(I)= sample points, radius(I)= correspoinding points
%and interp_angles = coordinates of the querry points (QP)
%In general, the functions returns interpolated values at specific QP
interp_distances = interp1(angles(I),radius(I),interp_angles,’linear’,’extrap’);
% 7.8 Plot distance vs. angle.
plot(ax4,interp_angles,interp_distances)
end
%8. Apply fft algorithm to values of radius
L = length(interp_distances); %Define the number of the radiuses (points)
f = 0:L-1; %Define the sampling frequencies
A = fft(interp_distances); %Transforming the radius function into frequency domain using FFT
B = (abs(A)/2535.2); % Normalize the amplitude of fourier descriptors using the first descriptors
%9. Plot fft descriptor vs. frequency
subplot(3,3,5)
bar(f,B,3) %plot the frequencies vs. the nornalised descriptors
xlim([0 128])
%10. Plot phase angle vs. frequency
subplot(3,3,6)
bar(f, angle(A),3) % plot the frequencies vs phase angles
xlim([0 128])
ylim([-4 4])
%11. Create a table of values
table1 = table(A, f’, abs(A), B, angle(A));
table1.Properties.VariableNames = {‘FFT_coeffs’, ‘Frequency’, ‘Amplitude’, ‘Norm_Amplitude’ ‘Phase’};
disp(table1);
%12. Reconstruct particle boundary using FFT descriptors ????? fft, shape reconstruction, fourier descriptor MATLAB Answers — New Questions
How to treat 200 rows of data as an event when constructing a Timetable, as a piece of data, the size is 200*1
There is a table, if the sampling rate is set to 200 when constructing the Timetable,TT = timetable(var,’SampleRate’,200) ,then the time of each row of the Timetable is 0.005s, 0.01s etc, but what I want is that the time of each row is 1s, 2s, 3s, and the corresponding var data shape of each row is 200*1, what should I do?There is a table, if the sampling rate is set to 200 when constructing the Timetable,TT = timetable(var,’SampleRate’,200) ,then the time of each row of the Timetable is 0.005s, 0.01s etc, but what I want is that the time of each row is 1s, 2s, 3s, and the corresponding var data shape of each row is 200*1, what should I do? There is a table, if the sampling rate is set to 200 when constructing the Timetable,TT = timetable(var,’SampleRate’,200) ,then the time of each row of the Timetable is 0.005s, 0.01s etc, but what I want is that the time of each row is 1s, 2s, 3s, and the corresponding var data shape of each row is 200*1, what should I do? timetable MATLAB Answers — New Questions