Hello!
I want to implement the following matrix:
Can anyone show me how to do that?

2 Comments

Implement how?
I have given a vector and from this I want to create the matrix

Sign in to comment.

 Accepted Answer

n=3;
>> x=ceil(5*rand(1,n+1))
x =
3 5 1 3
>> M=fliplr(vander(x))
M =
1 3 9 27
1 5 25 125
1 1 1 1
1 3 9 27

12 Comments

I don't know the functions fliplr and vander, is there an easier way to do it?
Well if I assume using only stricty things you know, I'll end up unable to answer your question.
You kow this?
x(:) .^ (0:length(x)-1)
or this?
M = zeros(length(x));
for k=0:length(x)-1
for i=1:length(x)
M(i,k+1) = x(i)^k;
end
end
or this?
y=x(:);
u=ones(size(y));
M = [u y.*[u y.*[u y]]]
or this?
u = ones(size(x(:)));
M = u(:,[]);
for j=1:length(x)
M = [u, x(:).*M];
end
thank you, that's what I was looking for.
It’s wrong. Should be without -1
Bruno Luong
Bruno Luong on 18 Jul 2020
Edited: Bruno Luong on 18 Jul 2020
Think more carefully madhan, n is length(x)-1 (you store where x_0?)
That's right Bruno!
And another question:
I created y=1+sin(x(:)).^2 but the output is wrong, why?
What's the relationship between y=1+sin(x(:)).^2 and the codes I showed you?
I have to solve inv(matrix)*y at the end
How can you expect me to guess what is wrong without knowing x, or what is solution you expect ? and is the solution you get with MATLAB? or what exact MATLAB code you try?
I need a crystal ball.
x is a random vector with n indices, I get the first solution at f and the others are all 0, which is wrong
I got it now!
Bruno Luong
Bruno Luong on 18 Jul 2020
Edited: Bruno Luong on 18 Jul 2020
Then your code is likely wrong. You want me to point out where it's wrong? Let me look at my christal-ball: it tells me line #4, column #7 of your MATLAB script

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!