How to write this b in matrix form in matlab?

88 Views Asked by At

enter image description here

Can anyone help me write this b in matrix form in matlab?

I am letting n=10 for the dimension of A.

2

There are 2 best solutions below

5
On BEST ANSWER

Is this a vector? What is A? Is n a constant?

Can you write down what is the value of $b_{i,j}$?

Assuming b is a vector with n elements such that for $i\ne 1$ or $n$ then $b_i = \frac{i^2}{(n+1)^4}$

then in matlab you can write

n = 10;
i = 2:(n-1);
bmid = i.^2 / ((n+1).^4);
b = [1+1/(n+1)^4, bmid, 6+(n^2)/(n+1)^4];
0
On

I'm sure there's some clever MATLAB syntax that would make this more compact, but you could always do a for loop

n = 10;
b = [1 + 1/(n+1)^4]
for i = 2:n-1
    b = [b;i^2/(n+1)^4];
end
b = [b;6 + n^2/(n+1)^4];