scalar to vector formation, k = [k1 k2 k3 k4] to [k1,-k1,0,​0:-k1,k1+k​2,-k2,0:0,​-k2,k2+k3,​0:0,0,-k3,​k3+k4]

2 views (last 30 days)

Accepted Answer

Stephen23
Stephen23 on 25 Nov 2018
Edited: Stephen23 on 25 Nov 2018
k = [0.6337,0.6337,0.6337,0.6337];
n = numel(k);
m = zeros(n);
m(2:n+1:end-n) = 0-k(1:end-1); % lower
m(1+n:n+1:end) = 0-k(1:end-1); % upper
m(1:n+1:end) = [0,k(1:end-1)]+k % main
Giving:
m =
0.63370 -0.63370 0.00000 0.00000
-0.63370 1.26740 -0.63370 0.00000
0.00000 -0.63370 1.26740 -0.63370
0.00000 0.00000 -0.63370 1.26740

More Answers (0)

Categories

Find more on Elementary Math in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!