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]

 Accepted Answer

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 Comment

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];

Sign in to comment.

More Answers (0)

Categories

Find more on Green Vehicles in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!