How to find function for many parameters?

조회 수: 1 (최근 30일)
Ammy
Ammy 2021년 9월 14일
답변: Image Analyst 2021년 9월 14일
let
A=randperm(16);
A=reshape(A,4,4);
I have the following function
function [B]=fun(A,a,b,c)
B= a.*A+b.*A+c.*A
end
Now I want to find B with different parameters
a,b,c
1, 2,3
6,1,4
7,3,5
for a single set I can find [B]=fun(A,1,2,3)
but I have many parameters, is there any way to save parameters in a separte file and run the code for all these and save all the results.

채택된 답변

KSSV
KSSV 2021년 9월 14일
vals = [1, 2,3
6,1,4
7,3,5] ;
[m,n] =size(vals) ;
B = zeros(4,4,m) ;
for i = 1:m
B(:,:,i)=fun(A,vals(i,1),vals(i,2),vals(i,3)) ;
end

추가 답변 (1개)

Image Analyst
Image Analyst 2021년 9월 14일
You can use the save() function to "save parameters in a separte file" and recall them later.

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by