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
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by