Is there a code to take values from the fprintf ?

fprintf('% 5d %8.3i %8.3i\n',i,strain,stress)
is there a code that can extract the last column of my fprint? the stresses?
thank you very much in advance

 채택된 답변

Star Strider
Star Strider 2020년 11월 9일

0 개 추천

Since you are printing to the Command Window and not a file, likely not.
However ‘stress’ is obviously in your workspace, so there is no need for you to extract it. Just use the value you have.

댓글 수: 4

James Tursa
James Tursa 2020년 11월 9일
편집: James Tursa 2020년 11월 9일
Assuming your current loop looks like this
for i=1:n
% some calculations here
stress = (some expression);
end
you would change stress to a vector, e.g.
stress = zeros(1,n);
for i=1:n
% some calculations here
stress(i) = (some expression);
end
James Tursa — Thank you!
I’d not considered that possibility.
@Star: I was actually responding to a comment made by OP, which has since been deleted for some reason.
Interesting. I never saw it, so I didn’t delete it.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2020년 11월 9일

댓글:

2020년 11월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by