Asked by CodeElinesa
on 28 Feb 2018

the problem here is this vector must be found from c = A\b. A and b are created from two variables x and y. (I posted the image of example xi,yi). x and y come from the normal parabola(ax^2 + bx +c) first, then they could be used in the matrix to form A and b. if my question is too confusing, just see the image...sorry, I am not good at explaining a problem :c Is there a way to solve it ? Thank you.

Answer by Roger Stafford
on 28 Feb 2018

Edited by Stephen Cobeldick
on 28 Feb 2018

Assume your xi's and yi's are given by a couple of column vectors, x and y of the same length.

n = length(x);

A = [x.^(n-1:-1:0)];

c = A\y;

CodeElinesa
on 28 Feb 2018

Roger Stafford
on 28 Feb 2018

If you have an older version of matlab, use

A = bsxfun(@power,x,((n-1):-1:0));

where again I assume x is a column vector.

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 3 Comments

## Roger Stafford (view profile)

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/385320-how-to-create-a-specific-vector-c-that-has-two-variables-x-and-y#comment_540313

## CodeElinesa (view profile)

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/385320-how-to-create-a-specific-vector-c-that-has-two-variables-x-and-y#comment_540315

## CodeElinesa (view profile)

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/385320-how-to-create-a-specific-vector-c-that-has-two-variables-x-and-y#comment_540316

Sign in to comment.