Set breakpoint is not working in Method function file.

2 vues (au cours des 30 derniers jours)
younghwa park
younghwa park le 26 Juin 2024
Commenté : younghwa park le 27 Juin 2024
Hi
I would like set break point at reduce function in PDEtoobox. How can I achieve that.
Below is minimum viable code.
How can I add break point reduce function?
Thanks for help!
clc
clear all
open reduce
modelT = createpde("structural","transient-solid");
gm = multicuboid(0.05,0.003,0.003);
modelT.Geometry = gm;
figure
pdegplot(modelT,"FaceLabels","on","FaceAlpha",0.5)
view([71 4])
structuralProperties(modelT,"YoungsModulus",210E9, ...
"PoissonsRatio",0.3, ...
"MassDensity",7800);
structuralBC(modelT,"Edge",[2 8 11 12],"Constraint","fixed");
loadedVertex = addVertex(gm,"Coordinates",[0.025 0.0 0.0015]);
generateMesh(modelT);
structuralBoundaryLoad(modelT,"Vertex",loadedVertex, ...
"Force",[0;0;10],"Frequency",6000);
structuralIC(modelT,"Velocity",[0 0 0],"Displacement",[0 0 0]);
structuralSEInterface(modelT,"Edge",[2 8 11 12]);
structuralSEInterface(modelT,"Vertex",loadedVertex);
rom = reduce(modelT,"FrequencyRange",[-0.1,5e5]);

Réponse acceptée

Walter Roberson
Walter Roberson le 26 Juin 2024
modelT = createpde("structural","transient-solid");
which reduce(modelT, 'FrequencyRange', [1 2])
That will tell you the name of the file containing the reduce method of StructuralModel objects. Once you know that, you can
dbstop in +pde/@StructuralModel/reduce.m
Note that this is a method of an object, and that it is not the same as the reduce that would be found by default, which would be toolbox/pde/@femodel/reduce.m

Plus de réponses (1)

Shubham
Shubham le 26 Juin 2024
Hi Younghwa,
To set a breakpoint in a specific function (such as reduce) in MATLAB, you need to locate the function's source code file. Once you have located the file, you can set a breakpoint either through the MATLAB Editor or programmatically.
Steps to Set a Breakpoint in the reduce Function:
  1. Locate the Source Code of the reduce Function: Use the which command to find the location of the reduce function.
which reduce
2. Open the Source Code File: Use the edit command to open the source code file in the MATLAB Editor.
edit reduce
3. Set a Breakpoint in the MATLAB Editor: In the MATLAB Editor, navigate to the line where you want to set the breakpoint and click on the margin next to the line number to set the breakpoint. Alternatively, you can set a breakpoint programmatically using the dbstop command.
Example of Setting a Breakpoint Programmatically:
  1. Locate the Source Code File: First, locate the file using the which command.
fileLocation = which('reduce');
disp(fileLocation);
2. Set a Breakpoint at a Specific Line Number: Assuming you know the specific line number where you want to set the breakpoint, you can use the dbstop command. For example, if you want to set the breakpoint at line 10:
dbstop in reduce at 10
Applying This to Your Example Code: Here’s how you can incorporate the steps into your example code:
clc;
clear all;
% Locate the source code file for the reduce function
fileLocation = which('reduce');
disp(['reduce function is located at: ', fileLocation]);
% Open the reduce function in the MATLAB Editor
edit reduce;
% Optionally, set a breakpoint programmatically at a known line number
% dbstop in reduce at 10 % Uncomment and adjust the line number accordingly
% Your existing code
modelT = createpde("structural","transient-solid");
gm = multicuboid(0.05,0.003,0.003);
modelT.Geometry = gm;
figure
pdegplot(modelT,"FaceLabels","on","FaceAlpha",0.5)
view([71 4])
structuralProperties(modelT,"YoungsModulus",210E9, ...
"PoissonsRatio",0.3, ...
"MassDensity",7800);
structuralBC(modelT,"Edge",[2 8 11 12],"Constraint","fixed");
loadedVertex = addVertex(gm,"Coordinates",[0.025 0.0 0.0015]);
generateMesh(modelT);
structuralBoundaryLoad(modelT,"Vertex",loadedVertex, ...
"Force",[0;0;10],"Frequency",6000);
structuralIC(modelT,"Velocity",[0 0 0],"Displacement",[0 0 0]);
structuralSEInterface(modelT,"Edge",[2 8 11 12]);
structuralSEInterface(modelT,"Vertex",loadedVertex);
rom = reduce(modelT,"FrequencyRange",[-0.1,5e5]);
Summary:
  • Use which to locate the source code file of the reduce function.
  • Open the file using edit.
  • Set a breakpoint in the MATLAB Editor or programmatically using dbstop.
By following these steps, you can set a breakpoint in the reduce function and debug your code effectively.

Catégories

En savoir plus sur Stress and Strain dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by