Category: Matlab
Category Archives: Matlab
Grain boundary analysis of images
I have three TEM images taken at different tilt angles, each showing grain boundaries. However, some grain boundaries are missing in each image. I need a MATLAB code to overlay or merge these three images into a single image where the missing boundaries are filled in, creating a more complete representation of the grain structure.
Attached are the imagesI have three TEM images taken at different tilt angles, each showing grain boundaries. However, some grain boundaries are missing in each image. I need a MATLAB code to overlay or merge these three images into a single image where the missing boundaries are filled in, creating a more complete representation of the grain structure.
Attached are the images I have three TEM images taken at different tilt angles, each showing grain boundaries. However, some grain boundaries are missing in each image. I need a MATLAB code to overlay or merge these three images into a single image where the missing boundaries are filled in, creating a more complete representation of the grain structure.
Attached are the images grain boundary MATLAB Answers — New Questions
Why is trailing back space removed from my folder name?
I have a subfolder named .results (I give the whole name)
Allowing the user to change it I have name app.defOutLoc as default and the app.OutLoc once confirmed.
app.OutLoc = app.defOutLoc;
K>> defOutLoc
defOutLoc =
"C:UsersCPSLabDocumentsOdorChoiceDevresults"
K>> app.OutLoc
ans =
"C:UsersCPSLabDocumentsOdorChoiceDevresults"
So when I add the folder name to file name I end up saving resultsMyFileName.txt in the parent folder
Who asked you to trim my ? and what do I do now?
I’ve added at some points
% Don’t forget the ending
app.OutLoc = append(app.OutLoc,"");
but now need to chase down every time I do an assignment and add it back!
You would think it could at least be done right here where I build the name:
app.StartSessionTime = …
char(datetime(‘now’,’Format’,"_yyMMdd_HHmmss"));
baseFileName = append(app.MouseName.Value, …
app.StartSessionTime);
app.SessionFileName = append(app.OutLoc, …
"MC_",baseFileName,"_session.m");
app.SessionFile = fopen(app.SessionFileName,’at’); % allow appending
I suppose there is some special way to combine file parts instead of append where ML put it back that I missed.
OK I found fullfile() Now to get it to properly put all the pieces together. Like this?
app.SessionFileName = fullfile(app.OutLoc, append("MC_",baseFileName,"_session"),"m";I have a subfolder named .results (I give the whole name)
Allowing the user to change it I have name app.defOutLoc as default and the app.OutLoc once confirmed.
app.OutLoc = app.defOutLoc;
K>> defOutLoc
defOutLoc =
"C:UsersCPSLabDocumentsOdorChoiceDevresults"
K>> app.OutLoc
ans =
"C:UsersCPSLabDocumentsOdorChoiceDevresults"
So when I add the folder name to file name I end up saving resultsMyFileName.txt in the parent folder
Who asked you to trim my ? and what do I do now?
I’ve added at some points
% Don’t forget the ending
app.OutLoc = append(app.OutLoc,"");
but now need to chase down every time I do an assignment and add it back!
You would think it could at least be done right here where I build the name:
app.StartSessionTime = …
char(datetime(‘now’,’Format’,"_yyMMdd_HHmmss"));
baseFileName = append(app.MouseName.Value, …
app.StartSessionTime);
app.SessionFileName = append(app.OutLoc, …
"MC_",baseFileName,"_session.m");
app.SessionFile = fopen(app.SessionFileName,’at’); % allow appending
I suppose there is some special way to combine file parts instead of append where ML put it back that I missed.
OK I found fullfile() Now to get it to properly put all the pieces together. Like this?
app.SessionFileName = fullfile(app.OutLoc, append("MC_",baseFileName,"_session"),"m"; I have a subfolder named .results (I give the whole name)
Allowing the user to change it I have name app.defOutLoc as default and the app.OutLoc once confirmed.
app.OutLoc = app.defOutLoc;
K>> defOutLoc
defOutLoc =
"C:UsersCPSLabDocumentsOdorChoiceDevresults"
K>> app.OutLoc
ans =
"C:UsersCPSLabDocumentsOdorChoiceDevresults"
So when I add the folder name to file name I end up saving resultsMyFileName.txt in the parent folder
Who asked you to trim my ? and what do I do now?
I’ve added at some points
% Don’t forget the ending
app.OutLoc = append(app.OutLoc,"");
but now need to chase down every time I do an assignment and add it back!
You would think it could at least be done right here where I build the name:
app.StartSessionTime = …
char(datetime(‘now’,’Format’,"_yyMMdd_HHmmss"));
baseFileName = append(app.MouseName.Value, …
app.StartSessionTime);
app.SessionFileName = append(app.OutLoc, …
"MC_",baseFileName,"_session.m");
app.SessionFile = fopen(app.SessionFileName,’at’); % allow appending
I suppose there is some special way to combine file parts instead of append where ML put it back that I missed.
OK I found fullfile() Now to get it to properly put all the pieces together. Like this?
app.SessionFileName = fullfile(app.OutLoc, append("MC_",baseFileName,"_session"),"m"; folderfile name MATLAB Answers — New Questions
Error: Time object cannot be empty
Hi matlab community,
when i tried to generate code from simulink, there is an error:
Internal error while creating code interface description file: codeInfo.mat. Aborting code generation.
Caused by:
Time object cannot be empty
I have tried the which codeInfo.mat -all methods, but it seems not helpful. When I restart the matlab again, it works once, but it always fails after the first run.
Best,
YutingHi matlab community,
when i tried to generate code from simulink, there is an error:
Internal error while creating code interface description file: codeInfo.mat. Aborting code generation.
Caused by:
Time object cannot be empty
I have tried the which codeInfo.mat -all methods, but it seems not helpful. When I restart the matlab again, it works once, but it always fails after the first run.
Best,
Yuting Hi matlab community,
when i tried to generate code from simulink, there is an error:
Internal error while creating code interface description file: codeInfo.mat. Aborting code generation.
Caused by:
Time object cannot be empty
I have tried the which codeInfo.mat -all methods, but it seems not helpful. When I restart the matlab again, it works once, but it always fails after the first run.
Best,
Yuting simulink, code generation MATLAB Answers — New Questions
MATLAB Permission Issue Across Multiple Users on Windows 10
Hello folks,
I am trying to install MATLAB as the administrator on a common use Windows 10 machine. This machine has multiple user accounts that will each be using MATLAB from their this source installation.
When MATLAB is opened from the main admin account, there is no issue. However, when MATLAB is opened from any of the other user accounts the following errors are given in the command window:
Previously accessible file "C:Program FilesMATLABR2022atoolboxlocalpathdef.m" is now inaccessible.
Warning: MATLAB did not appear to successfully set the search path. To recover for this session of MATLAB, type "restoredefaultpath;matlabrc". To find out how to avoid this
warning the next time you start MATLAB, type "docsearch problem path" after recovering for this session.
Undefined function ‘usejava’ for input arguments of type ‘char’.
Warning: MATLAB did not appear to successfully set the search path. To recover for this session of MATLAB, type "restoredefaultpath;matlabrc". To find out how to avoid this
warning the next time you start MATLAB, type "docsearch problem path" after recovering for this session.
Warning: Initializing Java preferences failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:UndefinedFunction
Unrecognized function or variable ‘initdesktoputils’.
com.mathworks.mvm.exec.MvmExecutionException: internal.matlab.desktop.editor.breakpointsForAllFiles
at com.mathworks.mvm.exec.NativeFutureResult.nativeGet(Native Method)
at com.mathworks.mvm.exec.NativeFutureResult.get(NativeFutureResult.java:62)
at com.mathworks.mvm.exec.FutureResult.getInternal(FutureResult.java:413)
at com.mathworks.mvm.exec.FutureFevalResult.getInternal(FutureFevalResult.java:49)
at com.mathworks.mvm.exec.FutureResult.get(FutureResult.java:263)
at com.mathworks.mlservices.MatlabDebugServices$3.run(MatlabDebugServices.java:978)
at com.mathworks.mvm.exec.NativeFutureResult.callRunnable(NativeFutureResult.java:146)
at com.mathworks.mvm.exec.NativeFutureResult.done(NativeFutureResult.java:138)
Caused by: com.mathworks.mvm.exec.MvmRuntimeException: Unrecognized function or variable ‘internal.matlab.desktop.editor.breakpointsForAllFiles’.
Unrecognized function or variable ‘matlab.internal.docsearchserver.getDocCenterLanguage’.
Unrecognized function or variable ‘connector.internal.lifecycle.callConnectorStarted’.
Unrecognized function or variable ‘fullfile’.
Error occurred during background graphics initialization: Undefined function ‘fullfile’ for input arguments of type ‘char’.
Unrecognized function or variable ‘matlab.supportpackagemanagement.internal.getInstalledSupportPackagesInfo’.
Unable to resolve the name ‘matlab.internal.doc.updateConnectorDocroot’.
Unable to resolve the name ‘matlab.internal.doc.updateCustomDocContent’.
Unable to resolve the name ‘matlab.internal.doc.search.configureSearchServer’.
Unrecognized function or variable ‘matlab.internal.debugger.breakpoints.initBreakpointsStoreInstance’.
Unrecognized function or variable ‘pwd’.
Unrecognized function or variable ‘matlab.unittest.internal.ui.toolstrip.getFileInfoForToolstrip’.
Unrecognized function or variable ‘matlab.internal.codingui.warmupProgrammingAids’.
I attempted to solve this issue by restoring the default pathing and saving it as pathdef.m in the C:Program FilesMATLABR2022atoolboxlocal folder:
restoredefaultpath; matlabrc
savepath C:Program FilesMATLABR2022atoolboxlocalpathdef.m
This would work for the current user I was logged in as, but when I switched to another user the same issue would occur. I can subvert this issue but forcing MATLAB to be run as Administrator upon startup, but this is not ideal for the security levels required on this machine.
I figure this issue has something to do with user permission levels, but I am unsure which files / directories and what persmission settings I should set up for my configuration. Any help would be greatly appreciated! Thank you.Hello folks,
I am trying to install MATLAB as the administrator on a common use Windows 10 machine. This machine has multiple user accounts that will each be using MATLAB from their this source installation.
When MATLAB is opened from the main admin account, there is no issue. However, when MATLAB is opened from any of the other user accounts the following errors are given in the command window:
Previously accessible file "C:Program FilesMATLABR2022atoolboxlocalpathdef.m" is now inaccessible.
Warning: MATLAB did not appear to successfully set the search path. To recover for this session of MATLAB, type "restoredefaultpath;matlabrc". To find out how to avoid this
warning the next time you start MATLAB, type "docsearch problem path" after recovering for this session.
Undefined function ‘usejava’ for input arguments of type ‘char’.
Warning: MATLAB did not appear to successfully set the search path. To recover for this session of MATLAB, type "restoredefaultpath;matlabrc". To find out how to avoid this
warning the next time you start MATLAB, type "docsearch problem path" after recovering for this session.
Warning: Initializing Java preferences failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:UndefinedFunction
Unrecognized function or variable ‘initdesktoputils’.
com.mathworks.mvm.exec.MvmExecutionException: internal.matlab.desktop.editor.breakpointsForAllFiles
at com.mathworks.mvm.exec.NativeFutureResult.nativeGet(Native Method)
at com.mathworks.mvm.exec.NativeFutureResult.get(NativeFutureResult.java:62)
at com.mathworks.mvm.exec.FutureResult.getInternal(FutureResult.java:413)
at com.mathworks.mvm.exec.FutureFevalResult.getInternal(FutureFevalResult.java:49)
at com.mathworks.mvm.exec.FutureResult.get(FutureResult.java:263)
at com.mathworks.mlservices.MatlabDebugServices$3.run(MatlabDebugServices.java:978)
at com.mathworks.mvm.exec.NativeFutureResult.callRunnable(NativeFutureResult.java:146)
at com.mathworks.mvm.exec.NativeFutureResult.done(NativeFutureResult.java:138)
Caused by: com.mathworks.mvm.exec.MvmRuntimeException: Unrecognized function or variable ‘internal.matlab.desktop.editor.breakpointsForAllFiles’.
Unrecognized function or variable ‘matlab.internal.docsearchserver.getDocCenterLanguage’.
Unrecognized function or variable ‘connector.internal.lifecycle.callConnectorStarted’.
Unrecognized function or variable ‘fullfile’.
Error occurred during background graphics initialization: Undefined function ‘fullfile’ for input arguments of type ‘char’.
Unrecognized function or variable ‘matlab.supportpackagemanagement.internal.getInstalledSupportPackagesInfo’.
Unable to resolve the name ‘matlab.internal.doc.updateConnectorDocroot’.
Unable to resolve the name ‘matlab.internal.doc.updateCustomDocContent’.
Unable to resolve the name ‘matlab.internal.doc.search.configureSearchServer’.
Unrecognized function or variable ‘matlab.internal.debugger.breakpoints.initBreakpointsStoreInstance’.
Unrecognized function or variable ‘pwd’.
Unrecognized function or variable ‘matlab.unittest.internal.ui.toolstrip.getFileInfoForToolstrip’.
Unrecognized function or variable ‘matlab.internal.codingui.warmupProgrammingAids’.
I attempted to solve this issue by restoring the default pathing and saving it as pathdef.m in the C:Program FilesMATLABR2022atoolboxlocal folder:
restoredefaultpath; matlabrc
savepath C:Program FilesMATLABR2022atoolboxlocalpathdef.m
This would work for the current user I was logged in as, but when I switched to another user the same issue would occur. I can subvert this issue but forcing MATLAB to be run as Administrator upon startup, but this is not ideal for the security levels required on this machine.
I figure this issue has something to do with user permission levels, but I am unsure which files / directories and what persmission settings I should set up for my configuration. Any help would be greatly appreciated! Thank you. Hello folks,
I am trying to install MATLAB as the administrator on a common use Windows 10 machine. This machine has multiple user accounts that will each be using MATLAB from their this source installation.
When MATLAB is opened from the main admin account, there is no issue. However, when MATLAB is opened from any of the other user accounts the following errors are given in the command window:
Previously accessible file "C:Program FilesMATLABR2022atoolboxlocalpathdef.m" is now inaccessible.
Warning: MATLAB did not appear to successfully set the search path. To recover for this session of MATLAB, type "restoredefaultpath;matlabrc". To find out how to avoid this
warning the next time you start MATLAB, type "docsearch problem path" after recovering for this session.
Undefined function ‘usejava’ for input arguments of type ‘char’.
Warning: MATLAB did not appear to successfully set the search path. To recover for this session of MATLAB, type "restoredefaultpath;matlabrc". To find out how to avoid this
warning the next time you start MATLAB, type "docsearch problem path" after recovering for this session.
Warning: Initializing Java preferences failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:UndefinedFunction
Unrecognized function or variable ‘initdesktoputils’.
com.mathworks.mvm.exec.MvmExecutionException: internal.matlab.desktop.editor.breakpointsForAllFiles
at com.mathworks.mvm.exec.NativeFutureResult.nativeGet(Native Method)
at com.mathworks.mvm.exec.NativeFutureResult.get(NativeFutureResult.java:62)
at com.mathworks.mvm.exec.FutureResult.getInternal(FutureResult.java:413)
at com.mathworks.mvm.exec.FutureFevalResult.getInternal(FutureFevalResult.java:49)
at com.mathworks.mvm.exec.FutureResult.get(FutureResult.java:263)
at com.mathworks.mlservices.MatlabDebugServices$3.run(MatlabDebugServices.java:978)
at com.mathworks.mvm.exec.NativeFutureResult.callRunnable(NativeFutureResult.java:146)
at com.mathworks.mvm.exec.NativeFutureResult.done(NativeFutureResult.java:138)
Caused by: com.mathworks.mvm.exec.MvmRuntimeException: Unrecognized function or variable ‘internal.matlab.desktop.editor.breakpointsForAllFiles’.
Unrecognized function or variable ‘matlab.internal.docsearchserver.getDocCenterLanguage’.
Unrecognized function or variable ‘connector.internal.lifecycle.callConnectorStarted’.
Unrecognized function or variable ‘fullfile’.
Error occurred during background graphics initialization: Undefined function ‘fullfile’ for input arguments of type ‘char’.
Unrecognized function or variable ‘matlab.supportpackagemanagement.internal.getInstalledSupportPackagesInfo’.
Unable to resolve the name ‘matlab.internal.doc.updateConnectorDocroot’.
Unable to resolve the name ‘matlab.internal.doc.updateCustomDocContent’.
Unable to resolve the name ‘matlab.internal.doc.search.configureSearchServer’.
Unrecognized function or variable ‘matlab.internal.debugger.breakpoints.initBreakpointsStoreInstance’.
Unrecognized function or variable ‘pwd’.
Unrecognized function or variable ‘matlab.unittest.internal.ui.toolstrip.getFileInfoForToolstrip’.
Unrecognized function or variable ‘matlab.internal.codingui.warmupProgrammingAids’.
I attempted to solve this issue by restoring the default pathing and saving it as pathdef.m in the C:Program FilesMATLABR2022atoolboxlocal folder:
restoredefaultpath; matlabrc
savepath C:Program FilesMATLABR2022atoolboxlocalpathdef.m
This would work for the current user I was logged in as, but when I switched to another user the same issue would occur. I can subvert this issue but forcing MATLAB to be run as Administrator upon startup, but this is not ideal for the security levels required on this machine.
I figure this issue has something to do with user permission levels, but I am unsure which files / directories and what persmission settings I should set up for my configuration. Any help would be greatly appreciated! Thank you. matlab, installation MATLAB Answers — New Questions
Do packages replace or supplement toolboxes from R2024b?
In the 2024b release notes: "A package is a collection of MATLAB® code, related files, and a package definition file." There’s a new set of tools to create and manage packages.
On the other hand, from the help center: "You can package MATLAB® files to create a toolbox to share with others. These files can include MATLAB code, data, apps, examples, and documentation. When you create a toolbox, MATLAB generates a single installation file (.mltbx) that enables you or others to install your toolbox." There’s a tool for packaging toolboxes.
These seem remarkably similar concepts, which makes me wonder why both things now exist. Do packages simply replace user-written toolboxes, or do toolboxes retain some useful features which are not shared by packages? Are there situations where I should choose one over the other, or is the newer mechanism superior in general?
It looks like packages can analyse dependencies and pull needed packages along with them, and maybe they integrate with repositories better than toolboxes, but I might have missed something else significant. As far as I can see, the package documentation ignores toolboxes.
It would be nice to understand what is happening here, and which mechanism I should adopt for distributing related code files.
(Note that MATLAB used the term package in a different way in the past, to mean what is now a namespace. I’m asking about the new package mechanism as of 2024b.)In the 2024b release notes: "A package is a collection of MATLAB® code, related files, and a package definition file." There’s a new set of tools to create and manage packages.
On the other hand, from the help center: "You can package MATLAB® files to create a toolbox to share with others. These files can include MATLAB code, data, apps, examples, and documentation. When you create a toolbox, MATLAB generates a single installation file (.mltbx) that enables you or others to install your toolbox." There’s a tool for packaging toolboxes.
These seem remarkably similar concepts, which makes me wonder why both things now exist. Do packages simply replace user-written toolboxes, or do toolboxes retain some useful features which are not shared by packages? Are there situations where I should choose one over the other, or is the newer mechanism superior in general?
It looks like packages can analyse dependencies and pull needed packages along with them, and maybe they integrate with repositories better than toolboxes, but I might have missed something else significant. As far as I can see, the package documentation ignores toolboxes.
It would be nice to understand what is happening here, and which mechanism I should adopt for distributing related code files.
(Note that MATLAB used the term package in a different way in the past, to mean what is now a namespace. I’m asking about the new package mechanism as of 2024b.) In the 2024b release notes: "A package is a collection of MATLAB® code, related files, and a package definition file." There’s a new set of tools to create and manage packages.
On the other hand, from the help center: "You can package MATLAB® files to create a toolbox to share with others. These files can include MATLAB code, data, apps, examples, and documentation. When you create a toolbox, MATLAB generates a single installation file (.mltbx) that enables you or others to install your toolbox." There’s a tool for packaging toolboxes.
These seem remarkably similar concepts, which makes me wonder why both things now exist. Do packages simply replace user-written toolboxes, or do toolboxes retain some useful features which are not shared by packages? Are there situations where I should choose one over the other, or is the newer mechanism superior in general?
It looks like packages can analyse dependencies and pull needed packages along with them, and maybe they integrate with repositories better than toolboxes, but I might have missed something else significant. As far as I can see, the package documentation ignores toolboxes.
It would be nice to understand what is happening here, and which mechanism I should adopt for distributing related code files.
(Note that MATLAB used the term package in a different way in the past, to mean what is now a namespace. I’m asking about the new package mechanism as of 2024b.) package, toolbox MATLAB Answers — New Questions
Convert .mat file to .dcm or .cdfx file
Is there a way to convert data stored in a .mat file to a .cdfx file?
The .mat file contains parameter data, including some parameters that are 3D matrices.
I use Silver to load a DLL, and Silver supports calibrating the DLL using the following five formats:
I am looking for a tool or a script that can do the conversion from .mat to any of the above mentioned formats without losing any information.Is there a way to convert data stored in a .mat file to a .cdfx file?
The .mat file contains parameter data, including some parameters that are 3D matrices.
I use Silver to load a DLL, and Silver supports calibrating the DLL using the following five formats:
I am looking for a tool or a script that can do the conversion from .mat to any of the above mentioned formats without losing any information. Is there a way to convert data stored in a .mat file to a .cdfx file?
The .mat file contains parameter data, including some parameters that are 3D matrices.
I use Silver to load a DLL, and Silver supports calibrating the DLL using the following five formats:
I am looking for a tool or a script that can do the conversion from .mat to any of the above mentioned formats without losing any information. calibration, cdfx, dcm, mat file MATLAB Answers — New Questions
Reshape EEG data to wide format with new aggregate column names
I’m using EEG lab to calculate relative spectral power for various bands. This went well, but now I’m stuck on how to reshape this the way I need it. I have 20 participants, and I want each participant to have only one row of data.
As such, I’m trying to convert this matrix so that the columns are a combination of electrode and frequency band. For example, each participant would have one row of data with columns labelled F7.relativeAlpha, F7.relativeBeta, and so on (see below for example). Any help would be greatly appreciated! I added an example of what I’m trying to create vs what I have currently.
I’ve tried unsuccessfully with the reshape function and with the unstack function.
RelativePowerWide = unstack(RelativePowerResults,’ID’,’RelativeDelta’)I’m using EEG lab to calculate relative spectral power for various bands. This went well, but now I’m stuck on how to reshape this the way I need it. I have 20 participants, and I want each participant to have only one row of data.
As such, I’m trying to convert this matrix so that the columns are a combination of electrode and frequency band. For example, each participant would have one row of data with columns labelled F7.relativeAlpha, F7.relativeBeta, and so on (see below for example). Any help would be greatly appreciated! I added an example of what I’m trying to create vs what I have currently.
I’ve tried unsuccessfully with the reshape function and with the unstack function.
RelativePowerWide = unstack(RelativePowerResults,’ID’,’RelativeDelta’) I’m using EEG lab to calculate relative spectral power for various bands. This went well, but now I’m stuck on how to reshape this the way I need it. I have 20 participants, and I want each participant to have only one row of data.
As such, I’m trying to convert this matrix so that the columns are a combination of electrode and frequency band. For example, each participant would have one row of data with columns labelled F7.relativeAlpha, F7.relativeBeta, and so on (see below for example). Any help would be greatly appreciated! I added an example of what I’m trying to create vs what I have currently.
I’ve tried unsuccessfully with the reshape function and with the unstack function.
RelativePowerWide = unstack(RelativePowerResults,’ID’,’RelativeDelta’) wide format, eeg, reshape, unstack MATLAB Answers — New Questions
cant get object’s method to return multiple outputs outputs
Hi, i cant get my method to return multiple outputs.
I have my object folder with the classdef
classdef crm < handle
%…
methods (Access = public)
[Tout,Yout]=runTimeDependent(self,n_0,tdata,nedata,Tedata)
end
end
And my function definition in a separate file inside the @crm folder
function [Tout,Yout]=runTimeDependent(self,n_0,tdata,nedata,Tedata)
TSPAN = [tdata(1) tdata(end)];
[Tout,Yout]=ode15s(@odefun,TSPAN,n_0);
function dydt=odefun(t,y)
% … ode function here
end
end
If i build my object and run the method everything works but if i ask 2 outputs i get an error
c=crm();
% definemy parameters ( Y0, t, ne, Te)
c.runTimeDependent(Y0,t,ne,Te); % This line works
[Tout, Yout] = c.runTimeDependent(Y0,t,ne,Te); %this line throws an error
Only when i ask both my outputs do i get an error
Error using indexing
Too many output arguments.
Error in test_timedep (line 4)
[Tout, Yout] = c.runTimeDependent(Y0,t,ne,Te);Hi, i cant get my method to return multiple outputs.
I have my object folder with the classdef
classdef crm < handle
%…
methods (Access = public)
[Tout,Yout]=runTimeDependent(self,n_0,tdata,nedata,Tedata)
end
end
And my function definition in a separate file inside the @crm folder
function [Tout,Yout]=runTimeDependent(self,n_0,tdata,nedata,Tedata)
TSPAN = [tdata(1) tdata(end)];
[Tout,Yout]=ode15s(@odefun,TSPAN,n_0);
function dydt=odefun(t,y)
% … ode function here
end
end
If i build my object and run the method everything works but if i ask 2 outputs i get an error
c=crm();
% definemy parameters ( Y0, t, ne, Te)
c.runTimeDependent(Y0,t,ne,Te); % This line works
[Tout, Yout] = c.runTimeDependent(Y0,t,ne,Te); %this line throws an error
Only when i ask both my outputs do i get an error
Error using indexing
Too many output arguments.
Error in test_timedep (line 4)
[Tout, Yout] = c.runTimeDependent(Y0,t,ne,Te); Hi, i cant get my method to return multiple outputs.
I have my object folder with the classdef
classdef crm < handle
%…
methods (Access = public)
[Tout,Yout]=runTimeDependent(self,n_0,tdata,nedata,Tedata)
end
end
And my function definition in a separate file inside the @crm folder
function [Tout,Yout]=runTimeDependent(self,n_0,tdata,nedata,Tedata)
TSPAN = [tdata(1) tdata(end)];
[Tout,Yout]=ode15s(@odefun,TSPAN,n_0);
function dydt=odefun(t,y)
% … ode function here
end
end
If i build my object and run the method everything works but if i ask 2 outputs i get an error
c=crm();
% definemy parameters ( Y0, t, ne, Te)
c.runTimeDependent(Y0,t,ne,Te); % This line works
[Tout, Yout] = c.runTimeDependent(Y0,t,ne,Te); %this line throws an error
Only when i ask both my outputs do i get an error
Error using indexing
Too many output arguments.
Error in test_timedep (line 4)
[Tout, Yout] = c.runTimeDependent(Y0,t,ne,Te); oop, output MATLAB Answers — New Questions
Variables from CSV column read incorrectly
After importing csv file into project, no issues are seen when file is opened in project folder window, however when put into a variable all numbers >100 are divide as such (e.g. 100 = 1.00, 200 = 2.00) this is seen for the variables under p. All outputs where this occurs are NaN
Variables are used for V3.06.16 of The Gibbs SeaWater (GSW) Oceanographic Toolbox gsw_SA_from_SP(SP,p,long,lat) function explained here https://www.teos-10.org/pubs/gsw/html/gsw_SA_from_SP.html. Although I don’t believe this is related to the issue.
The code used is as follows:
csv1 = ‘VL_69190_190228100353.csv’
data1 = readmatrix(csv1, ‘NumHeaderLines’, 1);
SP1 = data1(:, 4);
t1 = data1(:, 3);
p1 = data1(:, 2);
lat1 = 39.2404;
long1 = 2.3605;After importing csv file into project, no issues are seen when file is opened in project folder window, however when put into a variable all numbers >100 are divide as such (e.g. 100 = 1.00, 200 = 2.00) this is seen for the variables under p. All outputs where this occurs are NaN
Variables are used for V3.06.16 of The Gibbs SeaWater (GSW) Oceanographic Toolbox gsw_SA_from_SP(SP,p,long,lat) function explained here https://www.teos-10.org/pubs/gsw/html/gsw_SA_from_SP.html. Although I don’t believe this is related to the issue.
The code used is as follows:
csv1 = ‘VL_69190_190228100353.csv’
data1 = readmatrix(csv1, ‘NumHeaderLines’, 1);
SP1 = data1(:, 4);
t1 = data1(:, 3);
p1 = data1(:, 2);
lat1 = 39.2404;
long1 = 2.3605; After importing csv file into project, no issues are seen when file is opened in project folder window, however when put into a variable all numbers >100 are divide as such (e.g. 100 = 1.00, 200 = 2.00) this is seen for the variables under p. All outputs where this occurs are NaN
Variables are used for V3.06.16 of The Gibbs SeaWater (GSW) Oceanographic Toolbox gsw_SA_from_SP(SP,p,long,lat) function explained here https://www.teos-10.org/pubs/gsw/html/gsw_SA_from_SP.html. Although I don’t believe this is related to the issue.
The code used is as follows:
csv1 = ‘VL_69190_190228100353.csv’
data1 = readmatrix(csv1, ‘NumHeaderLines’, 1);
SP1 = data1(:, 4);
t1 = data1(:, 3);
p1 = data1(:, 2);
lat1 = 39.2404;
long1 = 2.3605; csv, r2024b MATLAB Answers — New Questions
Very new to this and need help making a contour plot that shows correlation between weight of powder, bullet seating depth, and group size.
First off im very new at this and attempting to figure my way though this. A little back story I am working on developing custom loads for my compition rifle. On a fourm another guy had a contour plot showing ideal loads based off his testing and I was hoping to replicate it (not able to use his program). For the inputs I would have 2 on the axis. One being the powder weight (in grains – gr) from 44.6 to 45.4 in 0.2 incriments. The second axis would be the bullet seating depth. This would be from 2.250" to 2.290" in 0.01" incraments. For the date i have loaded multiple batches of rounds. Out of these batches I will shoot and get a total group size for each.
Example:
44.6gr @ 2.290" = 0.912 MOA
44.8gr @ 2.290" = 0.661 MOA
45.0gr @ 2.290" = 0.995 MOA
45.2gr @ 2.290" = 1.200 MOA
45.4gr @ 2.29" = 0.663 MOA
I would continue this for each grain weight at the same seating depth. Then i would repeat the process with each grain weight at the next seating depth and so on untill I hvae gotten a group size for each combinination. I keep track of all of this on an excel spreadsheet and hope i can input that info as I would do this multiple times with different rifles and ammo load combinations.
(MOA is Minute of angle, used to measeure group size at any set distance, 1 MOA – 1.03" @ 100 yards)
I have added a photo of the plot I saw on the fourm. As it shows one axis has his powder weight, the other shows the seating depth (CBTO), the contour lines show group size and there are circles on there that show the measured group size for each batch of ammo. As the photo shows the smallest group size is trending towards 2.320" with aprox 44.6gr of powder. This would allow me to find the best combination of powder weight and seating depth to allow for the best group and have an allowable level or error between each batch.
I have spend a few hours trying to figure this out and have not nowhere. Is this something that would be easy to do and im just not getting it? If anyone could help me with this it would be greatly appreciated! Thank you!First off im very new at this and attempting to figure my way though this. A little back story I am working on developing custom loads for my compition rifle. On a fourm another guy had a contour plot showing ideal loads based off his testing and I was hoping to replicate it (not able to use his program). For the inputs I would have 2 on the axis. One being the powder weight (in grains – gr) from 44.6 to 45.4 in 0.2 incriments. The second axis would be the bullet seating depth. This would be from 2.250" to 2.290" in 0.01" incraments. For the date i have loaded multiple batches of rounds. Out of these batches I will shoot and get a total group size for each.
Example:
44.6gr @ 2.290" = 0.912 MOA
44.8gr @ 2.290" = 0.661 MOA
45.0gr @ 2.290" = 0.995 MOA
45.2gr @ 2.290" = 1.200 MOA
45.4gr @ 2.29" = 0.663 MOA
I would continue this for each grain weight at the same seating depth. Then i would repeat the process with each grain weight at the next seating depth and so on untill I hvae gotten a group size for each combinination. I keep track of all of this on an excel spreadsheet and hope i can input that info as I would do this multiple times with different rifles and ammo load combinations.
(MOA is Minute of angle, used to measeure group size at any set distance, 1 MOA – 1.03" @ 100 yards)
I have added a photo of the plot I saw on the fourm. As it shows one axis has his powder weight, the other shows the seating depth (CBTO), the contour lines show group size and there are circles on there that show the measured group size for each batch of ammo. As the photo shows the smallest group size is trending towards 2.320" with aprox 44.6gr of powder. This would allow me to find the best combination of powder weight and seating depth to allow for the best group and have an allowable level or error between each batch.
I have spend a few hours trying to figure this out and have not nowhere. Is this something that would be easy to do and im just not getting it? If anyone could help me with this it would be greatly appreciated! Thank you! First off im very new at this and attempting to figure my way though this. A little back story I am working on developing custom loads for my compition rifle. On a fourm another guy had a contour plot showing ideal loads based off his testing and I was hoping to replicate it (not able to use his program). For the inputs I would have 2 on the axis. One being the powder weight (in grains – gr) from 44.6 to 45.4 in 0.2 incriments. The second axis would be the bullet seating depth. This would be from 2.250" to 2.290" in 0.01" incraments. For the date i have loaded multiple batches of rounds. Out of these batches I will shoot and get a total group size for each.
Example:
44.6gr @ 2.290" = 0.912 MOA
44.8gr @ 2.290" = 0.661 MOA
45.0gr @ 2.290" = 0.995 MOA
45.2gr @ 2.290" = 1.200 MOA
45.4gr @ 2.29" = 0.663 MOA
I would continue this for each grain weight at the same seating depth. Then i would repeat the process with each grain weight at the next seating depth and so on untill I hvae gotten a group size for each combinination. I keep track of all of this on an excel spreadsheet and hope i can input that info as I would do this multiple times with different rifles and ammo load combinations.
(MOA is Minute of angle, used to measeure group size at any set distance, 1 MOA – 1.03" @ 100 yards)
I have added a photo of the plot I saw on the fourm. As it shows one axis has his powder weight, the other shows the seating depth (CBTO), the contour lines show group size and there are circles on there that show the measured group size for each batch of ammo. As the photo shows the smallest group size is trending towards 2.320" with aprox 44.6gr of powder. This would allow me to find the best combination of powder weight and seating depth to allow for the best group and have an allowable level or error between each batch.
I have spend a few hours trying to figure this out and have not nowhere. Is this something that would be easy to do and im just not getting it? If anyone could help me with this it would be greatly appreciated! Thank you! contour, plot, 3d plots MATLAB Answers — New Questions
How to resolve code generation errors caused by custom TLC file for custom C++ inlined S-Function within referenced model?
I have a custom C++ S-Function "sfun_Timestamp.cpp" that I am calling via an "S-Function" block within my Simulink model "Test_Timestamp.slx" in MATLAB R2021b. I am then calling "Test_Timestamp.slx" as a referenced model in "Test_Timestamp_Global.slx". I have written a custom TLC file "sfun_Timestamp.tlc" to inline my custom S-Function.
Simulating the top-level model "Test_Timestamp_Global.slx" that includes the S-Function inside the referenced model "Test_Timestamp.slx" works correctly. However, I observe the following build error when generating C++ code for "Test_Timestamp_Global.slx":
Component:Simulink | Category:Block diagram warning
### Invoking Target Language Compiler on Test_Timestamp.rtw
### Using System Target File: L:ML_MATLAB64R2021brtwcertert.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:ML_MATLAB64R2021brtwctlcblocksgensfun.tlc:BlockTypeSetup(585)
[01] L:ML_MATLAB64R2021brtwctlcprivate_apiblocksetuplib.tlc:BlockSetupAndCompatibilityCheck(113)
[02] L:ML_MATLAB64R2021brtwctlcmwcommonpass.tlc:<NONE>(53)
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:ML_MATLAB64R2021brtwctlcblocksgensfun.tlc:BlockInstanceSetup(378)
[01] L:ML_MATLAB64R2021brtwctlcprivate_apiblocksetuplib.tlc:BlockSetupAndCompatibilityCheck(134)
[02] L:ML_MATLAB64R2021brtwctlcmwcommonpass.tlc:<NONE>(53)
.
### Caching model source code
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:ML_MATLAB64R2021brtwctlcblocksgensfun.tlc:Outputs(1558)
[01] L:ML_MATLAB64R2021brtwctlcmwcommentlib.tlc:generateNonExprOutput(178)
[02] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:OpaqueTLCBlockFcn(5025)
[03] L:ML_WORKSPACEslprjertTest_Timestamptmwinternaltlcs1_b0_0zjfs_0_Outputs.tlc:Outputs(7)
[04] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:FcnGenRateGroupedCodeFromModule(5926)
[05] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:FcnGenerateCodeFromModule(5809)
[06] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:SLibFcnGenBodySysFcn(292)
[07] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:SLibFcnGenBodyFcnCache(509)
[08] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:SLibFcnGenBodySysFcnEntry(667)
[09] L:ML_MATLAB64R2021brtwctlcmwcommonbodlib.tlc:FcnGenBodySysCache(1900)
[10] L:ML_MATLAB64R2021brtwctlcmwcommonbodlib.tlc:SLibGenBodyCache(6478)
[11] L:ML_MATLAB64R2021brtwctlcmwformatwide.tlc:<NONE>(76)
.
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:ML_MATLAB64R2021brtwctlcblocksgensfun.tlc:BlockInstanceData(704)
[01] L:ML_MATLAB64R2021brtwctlcblockssubsystm.tlc:BlockInstanceData(35)
[02] L:ML_MATLAB64R2021brtwctlclibsyslib.tlc:LibCacheBlockInstanceData(6667)
[03] L:ML_MATLAB64R2021brtwctlcmwformatwide.tlc:<NONE>(92)
### Writing header file Test_Timestamp_types.h
### Writing header file Test_Timestamp.h
### Writing source file Test_Timestamp.cpp
.
### Writing header file Test_Timestamp_private.h
### TLC code generation complete.
### Build procedure for Test_Timestamp aborted due to an error.
Build Summary
Code generation targets built:
Model Action Rebuild Reason
=================================================================================================
Test_Timestamp Failed Dependency sfun_Timestamp.tlc of S-function sfun_Timestamp has changed.
0 of 2 models built (1 models already up to date)
Build duration: 0h 0m 2.464s
Error: Errors occurred – aborting
How can I resolve this build error and generate code?I have a custom C++ S-Function "sfun_Timestamp.cpp" that I am calling via an "S-Function" block within my Simulink model "Test_Timestamp.slx" in MATLAB R2021b. I am then calling "Test_Timestamp.slx" as a referenced model in "Test_Timestamp_Global.slx". I have written a custom TLC file "sfun_Timestamp.tlc" to inline my custom S-Function.
Simulating the top-level model "Test_Timestamp_Global.slx" that includes the S-Function inside the referenced model "Test_Timestamp.slx" works correctly. However, I observe the following build error when generating C++ code for "Test_Timestamp_Global.slx":
Component:Simulink | Category:Block diagram warning
### Invoking Target Language Compiler on Test_Timestamp.rtw
### Using System Target File: L:ML_MATLAB64R2021brtwcertert.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:ML_MATLAB64R2021brtwctlcblocksgensfun.tlc:BlockTypeSetup(585)
[01] L:ML_MATLAB64R2021brtwctlcprivate_apiblocksetuplib.tlc:BlockSetupAndCompatibilityCheck(113)
[02] L:ML_MATLAB64R2021brtwctlcmwcommonpass.tlc:<NONE>(53)
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:ML_MATLAB64R2021brtwctlcblocksgensfun.tlc:BlockInstanceSetup(378)
[01] L:ML_MATLAB64R2021brtwctlcprivate_apiblocksetuplib.tlc:BlockSetupAndCompatibilityCheck(134)
[02] L:ML_MATLAB64R2021brtwctlcmwcommonpass.tlc:<NONE>(53)
.
### Caching model source code
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:ML_MATLAB64R2021brtwctlcblocksgensfun.tlc:Outputs(1558)
[01] L:ML_MATLAB64R2021brtwctlcmwcommentlib.tlc:generateNonExprOutput(178)
[02] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:OpaqueTLCBlockFcn(5025)
[03] L:ML_WORKSPACEslprjertTest_Timestamptmwinternaltlcs1_b0_0zjfs_0_Outputs.tlc:Outputs(7)
[04] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:FcnGenRateGroupedCodeFromModule(5926)
[05] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:FcnGenerateCodeFromModule(5809)
[06] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:SLibFcnGenBodySysFcn(292)
[07] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:SLibFcnGenBodyFcnCache(509)
[08] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:SLibFcnGenBodySysFcnEntry(667)
[09] L:ML_MATLAB64R2021brtwctlcmwcommonbodlib.tlc:FcnGenBodySysCache(1900)
[10] L:ML_MATLAB64R2021brtwctlcmwcommonbodlib.tlc:SLibGenBodyCache(6478)
[11] L:ML_MATLAB64R2021brtwctlcmwformatwide.tlc:<NONE>(76)
.
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:ML_MATLAB64R2021brtwctlcblocksgensfun.tlc:BlockInstanceData(704)
[01] L:ML_MATLAB64R2021brtwctlcblockssubsystm.tlc:BlockInstanceData(35)
[02] L:ML_MATLAB64R2021brtwctlclibsyslib.tlc:LibCacheBlockInstanceData(6667)
[03] L:ML_MATLAB64R2021brtwctlcmwformatwide.tlc:<NONE>(92)
### Writing header file Test_Timestamp_types.h
### Writing header file Test_Timestamp.h
### Writing source file Test_Timestamp.cpp
.
### Writing header file Test_Timestamp_private.h
### TLC code generation complete.
### Build procedure for Test_Timestamp aborted due to an error.
Build Summary
Code generation targets built:
Model Action Rebuild Reason
=================================================================================================
Test_Timestamp Failed Dependency sfun_Timestamp.tlc of S-function sfun_Timestamp has changed.
0 of 2 models built (1 models already up to date)
Build duration: 0h 0m 2.464s
Error: Errors occurred – aborting
How can I resolve this build error and generate code? I have a custom C++ S-Function "sfun_Timestamp.cpp" that I am calling via an "S-Function" block within my Simulink model "Test_Timestamp.slx" in MATLAB R2021b. I am then calling "Test_Timestamp.slx" as a referenced model in "Test_Timestamp_Global.slx". I have written a custom TLC file "sfun_Timestamp.tlc" to inline my custom S-Function.
Simulating the top-level model "Test_Timestamp_Global.slx" that includes the S-Function inside the referenced model "Test_Timestamp.slx" works correctly. However, I observe the following build error when generating C++ code for "Test_Timestamp_Global.slx":
Component:Simulink | Category:Block diagram warning
### Invoking Target Language Compiler on Test_Timestamp.rtw
### Using System Target File: L:ML_MATLAB64R2021brtwcertert.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:ML_MATLAB64R2021brtwctlcblocksgensfun.tlc:BlockTypeSetup(585)
[01] L:ML_MATLAB64R2021brtwctlcprivate_apiblocksetuplib.tlc:BlockSetupAndCompatibilityCheck(113)
[02] L:ML_MATLAB64R2021brtwctlcmwcommonpass.tlc:<NONE>(53)
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:ML_MATLAB64R2021brtwctlcblocksgensfun.tlc:BlockInstanceSetup(378)
[01] L:ML_MATLAB64R2021brtwctlcprivate_apiblocksetuplib.tlc:BlockSetupAndCompatibilityCheck(134)
[02] L:ML_MATLAB64R2021brtwctlcmwcommonpass.tlc:<NONE>(53)
.
### Caching model source code
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:ML_MATLAB64R2021brtwctlcblocksgensfun.tlc:Outputs(1558)
[01] L:ML_MATLAB64R2021brtwctlcmwcommentlib.tlc:generateNonExprOutput(178)
[02] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:OpaqueTLCBlockFcn(5025)
[03] L:ML_WORKSPACEslprjertTest_Timestamptmwinternaltlcs1_b0_0zjfs_0_Outputs.tlc:Outputs(7)
[04] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:FcnGenRateGroupedCodeFromModule(5926)
[05] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:FcnGenerateCodeFromModule(5809)
[06] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:SLibFcnGenBodySysFcn(292)
[07] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:SLibFcnGenBodyFcnCache(509)
[08] L:ML_MATLAB64R2021brtwctlcmwopaquelib.tlc:SLibFcnGenBodySysFcnEntry(667)
[09] L:ML_MATLAB64R2021brtwctlcmwcommonbodlib.tlc:FcnGenBodySysCache(1900)
[10] L:ML_MATLAB64R2021brtwctlcmwcommonbodlib.tlc:SLibGenBodyCache(6478)
[11] L:ML_MATLAB64R2021brtwctlcmwformatwide.tlc:<NONE>(76)
.
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:ML_MATLAB64R2021brtwctlcblocksgensfun.tlc:BlockInstanceData(704)
[01] L:ML_MATLAB64R2021brtwctlcblockssubsystm.tlc:BlockInstanceData(35)
[02] L:ML_MATLAB64R2021brtwctlclibsyslib.tlc:LibCacheBlockInstanceData(6667)
[03] L:ML_MATLAB64R2021brtwctlcmwformatwide.tlc:<NONE>(92)
### Writing header file Test_Timestamp_types.h
### Writing header file Test_Timestamp.h
### Writing source file Test_Timestamp.cpp
.
### Writing header file Test_Timestamp_private.h
### TLC code generation complete.
### Build procedure for Test_Timestamp aborted due to an error.
Build Summary
Code generation targets built:
Model Action Rebuild Reason
=================================================================================================
Test_Timestamp Failed Dependency sfun_Timestamp.tlc of S-function sfun_Timestamp has changed.
0 of 2 models built (1 models already up to date)
Build duration: 0h 0m 2.464s
Error: Errors occurred – aborting
How can I resolve this build error and generate code? tlc, legacycodetool, sfunction, referencedmodel MATLAB Answers — New Questions
PID tuning PMSM motor
I am looking for a tool or Simulink project that is already complete where I can enter my motor parameters (and possibly inverter) and do some testing with PID tuning in the case of Field Oriented Control.
I found this: https://it.mathworks.com/help/mcb/gs/tune-pi-controllers-using-foc-autotuner.html?s_eid=PSM_15028 but I don’t understand if I can use it only via software without having to buy that motor and inveter.
Again, I am interested in doing PID tuning tests for my motor in the case of FOC, nothing more.
There is a lot of Simulink material online, so I ask for your help since I have little experience with Matlab
Thank you.I am looking for a tool or Simulink project that is already complete where I can enter my motor parameters (and possibly inverter) and do some testing with PID tuning in the case of Field Oriented Control.
I found this: https://it.mathworks.com/help/mcb/gs/tune-pi-controllers-using-foc-autotuner.html?s_eid=PSM_15028 but I don’t understand if I can use it only via software without having to buy that motor and inveter.
Again, I am interested in doing PID tuning tests for my motor in the case of FOC, nothing more.
There is a lot of Simulink material online, so I ask for your help since I have little experience with Matlab
Thank you. I am looking for a tool or Simulink project that is already complete where I can enter my motor parameters (and possibly inverter) and do some testing with PID tuning in the case of Field Oriented Control.
I found this: https://it.mathworks.com/help/mcb/gs/tune-pi-controllers-using-foc-autotuner.html?s_eid=PSM_15028 but I don’t understand if I can use it only via software without having to buy that motor and inveter.
Again, I am interested in doing PID tuning tests for my motor in the case of FOC, nothing more.
There is a lot of Simulink material online, so I ask for your help since I have little experience with Matlab
Thank you. matlab, simulink MATLAB Answers — New Questions
How can I plot a signal spectrum with an n-octave frequency scale in the Signal Analyzer?
I would like to visualize a signal spectrum in the Signal Analyzer with a frequency-spectrum plot that uses n-th octave bands in the frequency scale.
How can I achieve this?I would like to visualize a signal spectrum in the Signal Analyzer with a frequency-spectrum plot that uses n-th octave bands in the frequency scale.
How can I achieve this? I would like to visualize a signal spectrum in the Signal Analyzer with a frequency-spectrum plot that uses n-th octave bands in the frequency scale.
How can I achieve this? signalanalyzer, octave MATLAB Answers — New Questions
How to parallel Two three phase two level inverters in microgrid that is fed by renewables?
I have a microgrid consists of two three phase two level inverters which are operated in parallel with main grid. One inverter is fed by renewable while the other one fed by a battery-bank. When each inverter operates in parallel with main grid in either isolated or connected to main grid they do operate perfectly, but when the whole grid is assembled with two inverters in parallel with main grid, the whole grid goes in mis-function and the inverters cannot provide power to loads or inject to main grid.
Here are three simulink matlab files with whole network image, that are each inverter in parallel with main grid and the whole assembled grid. the first two work fine, but the last one does not operate synchronisingly and it goes in a big swing.
The scenario is:
The DG Inverter1 provides power all the times unless it goes under-rate, then DG Inverter2 connects to live network for peak shaving or to charge battery-bank, in either isolated mode or grid-connected modes. You can also define any other scenario.
I don’t know what to do to synchronise the network when two inverters are implemented, what should I do?
Is there any example available to study?
Thank you very much for any helpI have a microgrid consists of two three phase two level inverters which are operated in parallel with main grid. One inverter is fed by renewable while the other one fed by a battery-bank. When each inverter operates in parallel with main grid in either isolated or connected to main grid they do operate perfectly, but when the whole grid is assembled with two inverters in parallel with main grid, the whole grid goes in mis-function and the inverters cannot provide power to loads or inject to main grid.
Here are three simulink matlab files with whole network image, that are each inverter in parallel with main grid and the whole assembled grid. the first two work fine, but the last one does not operate synchronisingly and it goes in a big swing.
The scenario is:
The DG Inverter1 provides power all the times unless it goes under-rate, then DG Inverter2 connects to live network for peak shaving or to charge battery-bank, in either isolated mode or grid-connected modes. You can also define any other scenario.
I don’t know what to do to synchronise the network when two inverters are implemented, what should I do?
Is there any example available to study?
Thank you very much for any help I have a microgrid consists of two three phase two level inverters which are operated in parallel with main grid. One inverter is fed by renewable while the other one fed by a battery-bank. When each inverter operates in parallel with main grid in either isolated or connected to main grid they do operate perfectly, but when the whole grid is assembled with two inverters in parallel with main grid, the whole grid goes in mis-function and the inverters cannot provide power to loads or inject to main grid.
Here are three simulink matlab files with whole network image, that are each inverter in parallel with main grid and the whole assembled grid. the first two work fine, but the last one does not operate synchronisingly and it goes in a big swing.
The scenario is:
The DG Inverter1 provides power all the times unless it goes under-rate, then DG Inverter2 connects to live network for peak shaving or to charge battery-bank, in either isolated mode or grid-connected modes. You can also define any other scenario.
I don’t know what to do to synchronise the network when two inverters are implemented, what should I do?
Is there any example available to study?
Thank you very much for any help microgrid, simulink, inverter, renewable, synchronising inverters MATLAB Answers — New Questions
Legend for tiled donut charts
I have a 2×3 tiled layout.
In the first row, I put three donut charts (one per each "cell"). The figure is attached.
What I want to do is to put a unique legend for them in the whole second row. I saw that this is possible for other types of charts and interesting options were suggested to other users. The main problem is that the properties for the legend of donut charts are very limited.
Suggestions?
Thank you!I have a 2×3 tiled layout.
In the first row, I put three donut charts (one per each "cell"). The figure is attached.
What I want to do is to put a unique legend for them in the whole second row. I saw that this is possible for other types of charts and interesting options were suggested to other users. The main problem is that the properties for the legend of donut charts are very limited.
Suggestions?
Thank you! I have a 2×3 tiled layout.
In the first row, I put three donut charts (one per each "cell"). The figure is attached.
What I want to do is to put a unique legend for them in the whole second row. I saw that this is possible for other types of charts and interesting options were suggested to other users. The main problem is that the properties for the legend of donut charts are very limited.
Suggestions?
Thank you! donut chart, legend, tiled layout MATLAB Answers — New Questions
keep exact position of subplot axes
I want to plot three 2D projections of some 3D data. For compatibility with other images (our convention) I need to keep the position of the corresponding axes identical – see Fig.
Is there any (simple) way to do this? The layout in the image is the result of interactive manipulation with the size of the image – not entirely convenient 🙁
‘Subplot’ or ‘nexttile’ with tiledlayout(2,2,’TileSpacing’,’none’); can’t do it.
Of course, it would be possible to plot all the data in one axis (after a simple recalculation of the coordinates), but the advantage of individual axes for each (sub)projection would be lost …
function plot3x2D
close all
clear all
NN=10;
x=rand(1,NN);
y=rand(1,NN);
z=rand(1,NN);
val=rand(1,NN);
figure; hold on
axis off
a11=axes(‘pos’,[0.05 0.5 0.45 0.45],’XaxisLocation’,’top’,"Xdir",’reverse’);
hold on
scatter(x,y,val*200,val,’filled’,’Markerfacealpha’,0.6);
axis equal
set(gca,’xlim’,[0 1]);
set(gca,’ylim’,[0 1]);
box on
a12=axes(‘pos’,[0.5 0.5 0.45 0.45],’Yaxislocation’,’right’);
hold on
scatter(z,y,val*200,val,’filled’,’Markerfacealpha’,0.6);
axis equal
set(gca,’xlim’,[0 1]);
set(gca,’ylim’,[0 1]);
box on
a21=axes(‘pos’,[0.05 0.05 0.45 0.45],"Xdir",’reverse’);
hold on
scatter(x,z,val*200,val,’filled’,’Markerfacealpha’,0.6);
axis equal
set(gca,’xlim’,[0 1]);
set(gca,’ylim’,[0 1]);
box on
aa=1;
end
%==============eof==================I want to plot three 2D projections of some 3D data. For compatibility with other images (our convention) I need to keep the position of the corresponding axes identical – see Fig.
Is there any (simple) way to do this? The layout in the image is the result of interactive manipulation with the size of the image – not entirely convenient 🙁
‘Subplot’ or ‘nexttile’ with tiledlayout(2,2,’TileSpacing’,’none’); can’t do it.
Of course, it would be possible to plot all the data in one axis (after a simple recalculation of the coordinates), but the advantage of individual axes for each (sub)projection would be lost …
function plot3x2D
close all
clear all
NN=10;
x=rand(1,NN);
y=rand(1,NN);
z=rand(1,NN);
val=rand(1,NN);
figure; hold on
axis off
a11=axes(‘pos’,[0.05 0.5 0.45 0.45],’XaxisLocation’,’top’,"Xdir",’reverse’);
hold on
scatter(x,y,val*200,val,’filled’,’Markerfacealpha’,0.6);
axis equal
set(gca,’xlim’,[0 1]);
set(gca,’ylim’,[0 1]);
box on
a12=axes(‘pos’,[0.5 0.5 0.45 0.45],’Yaxislocation’,’right’);
hold on
scatter(z,y,val*200,val,’filled’,’Markerfacealpha’,0.6);
axis equal
set(gca,’xlim’,[0 1]);
set(gca,’ylim’,[0 1]);
box on
a21=axes(‘pos’,[0.05 0.05 0.45 0.45],"Xdir",’reverse’);
hold on
scatter(x,z,val*200,val,’filled’,’Markerfacealpha’,0.6);
axis equal
set(gca,’xlim’,[0 1]);
set(gca,’ylim’,[0 1]);
box on
aa=1;
end
%==============eof================== I want to plot three 2D projections of some 3D data. For compatibility with other images (our convention) I need to keep the position of the corresponding axes identical – see Fig.
Is there any (simple) way to do this? The layout in the image is the result of interactive manipulation with the size of the image – not entirely convenient 🙁
‘Subplot’ or ‘nexttile’ with tiledlayout(2,2,’TileSpacing’,’none’); can’t do it.
Of course, it would be possible to plot all the data in one axis (after a simple recalculation of the coordinates), but the advantage of individual axes for each (sub)projection would be lost …
function plot3x2D
close all
clear all
NN=10;
x=rand(1,NN);
y=rand(1,NN);
z=rand(1,NN);
val=rand(1,NN);
figure; hold on
axis off
a11=axes(‘pos’,[0.05 0.5 0.45 0.45],’XaxisLocation’,’top’,"Xdir",’reverse’);
hold on
scatter(x,y,val*200,val,’filled’,’Markerfacealpha’,0.6);
axis equal
set(gca,’xlim’,[0 1]);
set(gca,’ylim’,[0 1]);
box on
a12=axes(‘pos’,[0.5 0.5 0.45 0.45],’Yaxislocation’,’right’);
hold on
scatter(z,y,val*200,val,’filled’,’Markerfacealpha’,0.6);
axis equal
set(gca,’xlim’,[0 1]);
set(gca,’ylim’,[0 1]);
box on
a21=axes(‘pos’,[0.05 0.05 0.45 0.45],"Xdir",’reverse’);
hold on
scatter(x,z,val*200,val,’filled’,’Markerfacealpha’,0.6);
axis equal
set(gca,’xlim’,[0 1]);
set(gca,’ylim’,[0 1]);
box on
aa=1;
end
%==============eof================== particular subplots position MATLAB Answers — New Questions
How is ComponentProportion calculated by fitgmdist
I run fitgmdist on some data (total of 40 instances/samples) and and get a two-component Gaussian Mixture Model with ComponentProportion containing an array of two values: 0.8927 and 0.1073. Using the cluster method on the resulting gmdistribution, and passing in the original 40-element array, it returns an array of cluster IDs, 36 of which have the value "1", and 4 of which have the value "2". My expectation was that ComponentProportion would have contained exactly [0.9, 1.0] to reflect the ratios of cluster IDs in the data being fit. But apparently that’s not the case. Can anyone tell me where the actual ComponentProportion values come from? Thanks.I run fitgmdist on some data (total of 40 instances/samples) and and get a two-component Gaussian Mixture Model with ComponentProportion containing an array of two values: 0.8927 and 0.1073. Using the cluster method on the resulting gmdistribution, and passing in the original 40-element array, it returns an array of cluster IDs, 36 of which have the value "1", and 4 of which have the value "2". My expectation was that ComponentProportion would have contained exactly [0.9, 1.0] to reflect the ratios of cluster IDs in the data being fit. But apparently that’s not the case. Can anyone tell me where the actual ComponentProportion values come from? Thanks. I run fitgmdist on some data (total of 40 instances/samples) and and get a two-component Gaussian Mixture Model with ComponentProportion containing an array of two values: 0.8927 and 0.1073. Using the cluster method on the resulting gmdistribution, and passing in the original 40-element array, it returns an array of cluster IDs, 36 of which have the value "1", and 4 of which have the value "2". My expectation was that ComponentProportion would have contained exactly [0.9, 1.0] to reflect the ratios of cluster IDs in the data being fit. But apparently that’s not the case. Can anyone tell me where the actual ComponentProportion values come from? Thanks. gaussian mixture model fitgmdist gmdistribution componentproportion MATLAB Answers — New Questions
FixedwingGNC model issue while limiting it to guided taxi mission
Problem: I am encountering an issue with the taxi-guided mission in the Fixedwing GNC Simulink model, where the aircraft is not performing the takeoff sequence but should only taxi on the ground. I want the plane to stay on the ground and follow the waypoints without initiating flight.
Hardware: I am using the Pixhawk 6C with Hardware-in-the-Loop (HITL) simulation to monitor the output and perform tuning.
Actions Taken:
I have assigned waypoints with an altitude of 0 to ensure the aircraft stays on the ground.
I have set the Takeoff IC to unit8(0) to skip the takeoff sequence and directly start the mission at the waypoints.
I have included parameters such as {airspeedAltitude, lateralGuidance, Control.L1, control.cruisespeed, control.climbalt, and state.course} in the waypoints to feed the required data to the model, similar to the information available in the Takeoff block.
Current Behavior:
The model progresses through the waypoints but fails to turn towards the next waypoints as expected. The aircraft continues moving straight without any directional correction.
The data at the [send to Actuator] output block is showing zero, but the aircraft still moves.
Attempts Made: I have tried several configurations and adjustments to achieve the desired result, but I have been unable to resolve the issue.
Kindly guide me with this.Problem: I am encountering an issue with the taxi-guided mission in the Fixedwing GNC Simulink model, where the aircraft is not performing the takeoff sequence but should only taxi on the ground. I want the plane to stay on the ground and follow the waypoints without initiating flight.
Hardware: I am using the Pixhawk 6C with Hardware-in-the-Loop (HITL) simulation to monitor the output and perform tuning.
Actions Taken:
I have assigned waypoints with an altitude of 0 to ensure the aircraft stays on the ground.
I have set the Takeoff IC to unit8(0) to skip the takeoff sequence and directly start the mission at the waypoints.
I have included parameters such as {airspeedAltitude, lateralGuidance, Control.L1, control.cruisespeed, control.climbalt, and state.course} in the waypoints to feed the required data to the model, similar to the information available in the Takeoff block.
Current Behavior:
The model progresses through the waypoints but fails to turn towards the next waypoints as expected. The aircraft continues moving straight without any directional correction.
The data at the [send to Actuator] output block is showing zero, but the aircraft still moves.
Attempts Made: I have tried several configurations and adjustments to achieve the desired result, but I have been unable to resolve the issue.
Kindly guide me with this. Problem: I am encountering an issue with the taxi-guided mission in the Fixedwing GNC Simulink model, where the aircraft is not performing the takeoff sequence but should only taxi on the ground. I want the plane to stay on the ground and follow the waypoints without initiating flight.
Hardware: I am using the Pixhawk 6C with Hardware-in-the-Loop (HITL) simulation to monitor the output and perform tuning.
Actions Taken:
I have assigned waypoints with an altitude of 0 to ensure the aircraft stays on the ground.
I have set the Takeoff IC to unit8(0) to skip the takeoff sequence and directly start the mission at the waypoints.
I have included parameters such as {airspeedAltitude, lateralGuidance, Control.L1, control.cruisespeed, control.climbalt, and state.course} in the waypoints to feed the required data to the model, similar to the information available in the Takeoff block.
Current Behavior:
The model progresses through the waypoints but fails to turn towards the next waypoints as expected. The aircraft continues moving straight without any directional correction.
The data at the [send to Actuator] output block is showing zero, but the aircraft still moves.
Attempts Made: I have tried several configurations and adjustments to achieve the desired result, but I have been unable to resolve the issue.
Kindly guide me with this. px4, drones, uav, simulink, fixedwing, waypoints, matlab function, mission, taxi MATLAB Answers — New Questions
Hello everyone, can anyone provide me the matlab code of FD SLIC algorithm or FM SLIC algorithm
I am working on a project which requires the matlab code of FD SLIC algorithm …I am working on a project which requires the matlab code of FD SLIC algorithm … I am working on a project which requires the matlab code of FD SLIC algorithm … slic algorithm MATLAB Answers — New Questions
PLL Simulink 3 phase grid
Hi everybody,
I’ve found a Simulink model for a PLL for 3 phase grid. It works very well, but I don’t understand the purpose of a block called ‘actual amplitude detection’. It computes the followings: square of the magnitude, low pass filter the result (this is done for all the 3 phases), and then the maximum between the 3 signals. This value is then used to normalize the signals that represent the input grid.
Can you please tell me why is this done, why I cannot normalize the input grid with a fixed value (for example 400V)? Why is this method better, I don’t understand the principle, the theory behind this?
Many thanks,
MonicaHi everybody,
I’ve found a Simulink model for a PLL for 3 phase grid. It works very well, but I don’t understand the purpose of a block called ‘actual amplitude detection’. It computes the followings: square of the magnitude, low pass filter the result (this is done for all the 3 phases), and then the maximum between the 3 signals. This value is then used to normalize the signals that represent the input grid.
Can you please tell me why is this done, why I cannot normalize the input grid with a fixed value (for example 400V)? Why is this method better, I don’t understand the principle, the theory behind this?
Many thanks,
Monica Hi everybody,
I’ve found a Simulink model for a PLL for 3 phase grid. It works very well, but I don’t understand the purpose of a block called ‘actual amplitude detection’. It computes the followings: square of the magnitude, low pass filter the result (this is done for all the 3 phases), and then the maximum between the 3 signals. This value is then used to normalize the signals that represent the input grid.
Can you please tell me why is this done, why I cannot normalize the input grid with a fixed value (for example 400V)? Why is this method better, I don’t understand the principle, the theory behind this?
Many thanks,
Monica simulink pll normalization MATLAB Answers — New Questions