Loop input variables into function to get the various output in table
이전 댓글 표시
Hello!
I have a function for which i have some variables as input that create output as follows:
function(A,B,C,D,E,F,G) - So I input varibles A thru G and get the below output X thu Z
for i = 1:varout
switch i
case 1
varout{1} = X;
case 2
varout{2} = Y;
case 3
varout{3} = Z;
end
I have for example the following input variables I want to pass thru the function all at once for me to get a table with all the output variables given the input.
A B C D E F G X Y Z
1 2 1 2 6 7 1 =
3 1 1 8 7 4 10 =
1 5 1 2 6 3 8 =
Appreciate all the help in this matter! Thanks so much!
댓글 수: 8
Adam Danz
2022년 7월 18일
The question/goal is not clear.
I see you're using varout which suggests you expect a variable number of outputs. But you mention that the output should be a table so it's not clear how that all ties together.
Also, what are A,B,C,...,G? Could you provide examples of these inputs?
I have a feeling you're working with a variable number of inputs and want a single output variable that is a table containing the columns from your key when given the input variables. Is that right?
Adam Danz
2022년 7월 18일
That's helpful. How do those inputs map onto what the outputs should be?
IDN
2022년 7월 18일
Adam Danz
2022년 7월 18일
Where do those X,Y,Z values come from?
What should the program do?
IDN
2022년 7월 18일
Adam Danz
2022년 7월 18일
That should be easy to implement. If those are your variable names, then that's exactly the code you would use to produce those outputs. But I must admit, I am still quite uncertain of the goal.
IDN
2022년 7월 18일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!