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

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

Star Strider
Star Strider am 24 Sep. 2022
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
.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by