How to evaluate a vector into a Matrix?

I have to evaluate al values of L into the matrix Kelemento, but it evaluates in a way I dont wanto to, it evaluates for all values of L in the first row of kelemento instead of evaluating all the matrix for each vale of L
E= 3000
I=1
L=[4;5;1.5;1.5]
kelemento=[12*E*I./L.^3 6*E*I./L.^2 -12*E*I./L.^3 6*E*I./L.^2;
6*E*I./L.^2 4*E*I./L -6*E*I./L.^2 2*E*I./L;
-12*E*I./L.^3 -6*E*I./L.^2 12*E*I./L.^3 -6*E*I./L.^2;
6*E*I./L.^2 2*E*I./L -6*E*I./L.^2 4*E*I./L]

 采纳的回答

E= 3000;
I=1;
L=reshape( [4;5;1.5;1.5] , 1,1, []);
kelemento=[12*E*I./L.^3 6*E*I./L.^2 -12*E*I./L.^3 6*E*I./L.^2;
6*E*I./L.^2 4*E*I./L -6*E*I./L.^2 2*E*I./L;
-12*E*I./L.^3 -6*E*I./L.^2 12*E*I./L.^3 -6*E*I./L.^2;
6*E*I./L.^2 2*E*I./L -6*E*I./L.^2 4*E*I./L];
whos kelemento
Name Size Bytes Class Attributes kelemento 4x4x4 512 double

1 个评论

Thank you for your help, you gave me de clue, instead I needed
clear all
clc
E= 3000;
I=1;
L=reshape( [4;5;1.5;1.5] , 1,[],4);
kelemento=[12*E*I./L.^3 6*E*I./L.^2 -12*E*I./L.^3 6*E*I./L.^2;
6*E*I./L.^2 4*E*I./L -6*E*I./L.^2 2*E*I./L;
-12*E*I./L.^3 -6*E*I./L.^2 12*E*I./L.^3 -6*E*I./L.^2;
6*E*I./L.^2 2*E*I./L -6*E*I./L.^2 4*E*I./L];

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Green Vehicles 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by