Set breakpoint is not working in Method function file.
Mostrar comentarios más antiguos
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]);
Respuesta aceptada
Más respuestas (1)
Shubham
el 26 de Jun. de 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:
- 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:
- 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.
1 comentario
younghwa park
el 27 de Jun. de 2024
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!