Set breakpoint is not working in Method function file.
조회 수: 2 (최근 30일)
이전 댓글 표시
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]);
댓글 수: 0
채택된 답변
Walter Roberson
2024년 6월 26일
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
댓글 수: 0
추가 답변 (1개)
Shubham
2024년 6월 26일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Stress and Strain에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!