How to write in Matlab a matrix whose coefficients depend on a real alpha parameter
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Djamel
el 26 de Mzo. de 2024
Comentada: Djamel
el 2 de Abr. de 2024
A(i,j) = (1+alpha*x(i)*y(j))*exp(x(i)*y(j))
where almpha is a real parameter, x(i) and y(j) points in [0 , 1] with i , j = 1, ..., N
0 comentarios
Respuesta aceptada
John D'Errico
el 26 de Mzo. de 2024
Editada: John D'Errico
el 26 de Mzo. de 2024
Many ways. It seems unclear exactly what is your goal. And what are x and y? Are they just a list of numbers? Or a sequence as linspace would provide?
For example, you might do this:
N = 4;
x = linspace(0,1,N);
y = linspace(0,1,N);
syms alpha
A = (1+alpha*x.'*y)*exp(x.'*y)
vpa(A,5)
Of course, x and y might be just any arbitrary vectors of numbers.
Another approach would be to write it as a function handle. This time I'll use random vectors for x and y.
x = sort(rand(1,N))
y = sort(rand(1,N))
Afun = @(alph) (1+alph*x.'*y)*exp(x.'*y);
And now we can evaluate Afun for any value of the parameter.
Afun(0.3)
Más respuestas (1)
Voss
el 26 de Mzo. de 2024
Here's an example:
alpha = 0.4;
N = 9;
x = linspace(0,1,N);
y = linspace(0,1,N);
xy = x(:).*y(:).' % column x * row y
A = (1+alpha.*xy).*exp(xy)
0 comentarios
Ver también
Categorías
Más información sobre Spline Postprocessing 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!