How to find function for many parameters?

1 visualización (últimos 30 días)
Ammy
Ammy el 14 de Sept. de 2021
Respondida: Image Analyst el 14 de Sept. de 2021
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.

Respuesta aceptada

KSSV
KSSV el 14 de Sept. de 2021
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

Más respuestas (1)

Image Analyst
Image Analyst el 14 de Sept. de 2021
You can use the save() function to "save parameters in a separte file" and recall them later.

Categorías

Más información sobre Data Import and Analysis en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by