Run a function into a function
古いコメントを表示
Hi I have a function "a" called "function x=problem1(a,b,c,d)" I would like to create a function "b" that call function "a" and asign values to (a,b,c,d). Also, the function "b" have to run at least 6 times just with one call.
採用された回答
その他の回答 (4 件)
The question is not really clear. I assume that this is very basic and suggest to read the Getting Started chapters to learn the fundamentals of programming. But here a suggestion:
function b
for k = 1:6
a = rand;
b = 17.3;
c = k;
d = a + b + c ^ 2;
x = problem1(a,b,c,d);
disp(x);
end
Now look at the code and explain, what your problem is with any details.
Walter Roberson
2017 年 8 月 21 日
0 投票
Your question is not clear. Under one interpretation, you should see https://www.mathworks.com/matlabcentral/answers/353428-bad-cell-reference-with-cell-array-of-function-handles#answer_278631
Adrian Quesada
2017 年 8 月 21 日
編集済み: Adrian Quesada
2017 年 8 月 21 日
1 件のコメント
Walter Roberson
2017 年 8 月 21 日
Your existing code already handles the possibility that v will be a vector of length 5. Your existing code has b and c be optional. Are you talking about 5 different a values? If so, then would it be acceptable to just change
if v(k) == a
to
if ismember(v(k), a)
?
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!