If I have a function with 1 input producing 3 outputs; ran a small program loop to produce multiple outputs; how would I print out the input and 3 values in that order for the first 12 outputs.

If I have a function with 1 input producing 3 outputs; ran a small program loop to produce multiple outputs; how would I print out the input and 3 outputs in that order for the first 12 outputs.
I am having trouble formatting a fprintf for 4 values and I want to know if it is possible to stipulate the amount of values I want the fprint to print.

 채택된 답변

You mean something like this?
fprintf('Input: %d, Output1: %d, Output2: %d, Output3: %d\n', inp, out1, out2, out3);

댓글 수: 3

Yes, but when I put it in I MATLAB tells me I have unassigned values. The Function assfunct.m has output of a,b,A and input of P
for P=100:150
assfunct1(P);
fprintf('P: %d, a: %d, b: %d, A: %d\n', P, a, b, A);
end;
I would assume I'd want the output to be put into a vector before I can fprint the 12 values.
You are not reading the output values from the function assfunct1. Use this:
[a, b, A] = assfunct1(P);
You should see how the functions are used in MATLAB for a better understanding of it. It will help you.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

태그

질문:

2016년 5월 2일

댓글:

2016년 5월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by