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

1 vue (au cours des 30 derniers jours)
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

Réponse acceptée

Star Strider
Star Strider le 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
.
  2 commentaires
Star Strider
Star Strider le 24 Sep 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by