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