creating one output and 2 inputs function in script file
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ISMAYIL MAMMADOV
el 20 de En. de 2021
Hello everyone,
i have to write function in script file with a scala z and M matrix as inputs. M will be 20x20 random matrix, and z will has 100 distinct values between [-2 2] interval, and also i need plot this function.
M=randn(20,20);
n = 100;
R = [-2 2];
z = rand(n,1)*range(R)+min(R);
I=eye(20,20);
function out1 = f(z,M)
A=(M-z*I);
out1=det(A);
end
but i can not call function and get output values, please who can help me?
2 comentarios
Adam Danz
el 20 de En. de 2021
> i can not call function and get output values
You can call the function but you get errors. First, I is not defined in the function. Should that value be passed into the function? Then you have another problem. Z is 100x1 vector and I is 20*20 matrix, how were you planning on multiplying those variables? They do not conforum to requirements for matrix multiplication, they do not have the same number of elements for element-wise multiplication, and they do not conform the requirements of implicit expansion.
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Workspace Variables and MAT-Files en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!