how can i save my values of u into a vector, so i have the result of all the u-values.

1 回表示 (過去 30 日間)
for x=(0:0.1:1)
z=ones(1,11);
L=3.5;
v = [0.091, -0.061, 0.518, -0.07]';
N1 = 1 - 3*(x/L).^2 + 2*(x/L).^3;
N2 = x.*(1 - x/L).^2;
N3 = 3*(x/L).^2 - 2*(x/L).^3;
N4 = (x/L - 1).*x.^2/L;
u = N1*v(1) + N2*v(2) + N3*v(3) + N4*v(4)
end

採用された回答

Star Strider
Star Strider 2022 年 9 月 24 日
The loop is not necessary. Just use matrix multiplication.
One approach —
x=(0:0.1:1).'; % Column Vector (Creates The 'N' Values As Column Vectors)
L=3.5;
v = [0.091, -0.061, 0.518, -0.07]';
N1 = 1 - 3*(x/L).^2 + 2*(x/L).^3;
N2 = x.*(1 - x/L).^2;
N3 = 3*(x/L).^2 - 2*(x/L).^3;
N4 = (x/L - 1).*x.^2/L;
u = [N1 N2 N3 N4] * v % Matrix Multiplication
u = 11×1
0.0910 0.0865 0.0849 0.0862 0.0901 0.0965 0.1052 0.1159 0.1286 0.1429
.
  2 件のコメント
Star Strider
Star Strider 2022 年 9 月 24 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by