What I want to acheive is the following. Let's say I have the function if and .
I have two vectors with nodes: x and y and I would like to calculate the function mentioned abose as an array. I can do it straightforwardly as
A = zeros(length(x), length(y));
for i = 1 : length(x)
for j = 1 : length(y)
if (x(i) ~= y(j))
A(i,j) = sin(alpha*(x(i) - y(j))) / (alpha * (x(i) - y(j)));
A(i,j) = 1;
This way is not really fast. I would like to have a function that will produce similar output as this cycle. More precisely, I would like to have the output in the form which is applicable for the trapz() command to calculate the double integral after all
there K has been calculated previously
I was trying something loke this
function val = K(alp, x, y)
if (x ~= y)
val = sin(alp * (x - y)) ./ ( alp * (x - y) );
val = 1;
but, of course, it did not work. Could you tell me, please, how shall I rewrite this function to achieve what I mentioned?