error in matrix multiplication and integration
Show older comments
%%
clc;
clear;
syms x;
%pi = 180.;
% syms y_x;
% syms y_x_das;
L = 100.;
E = 29000. ;
c = 0.1*L;
d_0 = 5.;
d_1 = 2.*d_0;
d_x = 2.*d_0*(x/(2.*L));
b = 2.;
I_z = (b*d_x.^3)/12.;
G = 11000.;
A_x = b*d_x;
As = 5/6*A_x;
y_x = c*sin(2*pi*x/L);
y_x_das = diff(y_x);
theta_2 = atan(y_x_das);
Q_a = [-cos(theta_2) -sin(theta_2) 0];
Q_s = [-sin(theta_2) -cos(theta_2) 0];
Q_b = [-c*sin((2*pi*x)/L) x -1];
%%
%flexibility matrix
d1= sqrt(1 + y_x_das.^2).*((Q_a'.*Q_a)./(A_x*E));
d1_int = integral(@(x) d1(), 0, 100., 'ArrayValued', 1);
9 Comments
I got this to run, although the integral may not exist.
When I went to plot ‘d1’ to see what the function looked like (thinking that perhaps the singularities would show themselves), I got a matrix size incompatibility error.
Using arrayfun to see what the matrices look like, they all appear to be NaN(3) for every value of ‘yv’.
That needs to be investigated —
%%
clc;
clear;
% syms x;
%pi = 180.;
% syms y_x;
% syms y_x_das;
L = 100.;
E = 29000. ;
c = 0.1*L;
d_0 = 5.;
d_1 = 2.*d_0;
d_x = @(x) 2.*d_0*(x/(2.*L));
b = 2.;
I_z = @(x) (b*d_x(x).^3)/12.;
G = 11000.;
A_x = @(x) b*d_x(x);
As = @(x) 5/6*A_x(x);
y_x = @(x) c*sin(2*pi*x/L);
y_x_das = @(x) gradient(y_x(x))./gradient(x);
theta_2 = @(x) atan(y_x_das(x));
Q_a = @(x) [-cos(theta_2(x)) -sin(theta_2(x)) 0];
Q_s = @(x) [-sin(theta_2(x)) -cos(theta_2(x)) 0];
Q_b = @(x) [-c*sin((2*pi*x)/L) x -1];
%%
%flexibility matrix
d1 = @(x) sqrt(1 + y_x_das(x).^2).*((Q_a(x)'.*Q_a(x))./(A_x(x)*E));
d1_int = integral(@(x)d1(x), 1E-8, 100., 'ArrayValued', 1)
xv = linspace(0, 100);
yv = arrayfun(d1, xv, 'Unif',0);
yv{1}
yv{end}
.
Pi = sym(pi);
syms x real
L = 100.;
E = 29000. ;
c = 0.1*L;
d_0 = 5.;
d_1 = 2.*d_0;
d_x = @(x) 2.*d_0*(x/(2.*L));
b = 2.;
I_z = @(x) (b*d_x(x).^3)/12.;
G = 11000.;
A_x = @(x) b*d_x(x);
As = @(x) 5/6*A_x(x);
y_x = @(x) c*sin(2*Pi*x/L);
y_x_das = @(x) gradient(y_x(x))./gradient(x);
theta_2 = @(x) atan(y_x_das(x));
Q_a = @(x) [-cos(theta_2(x)) -sin(theta_2(x)) 0];
Q_s = @(x) [-sin(theta_2(x)) -cos(theta_2(x)) 0];
Q_b = @(x) [-c*sin((2*Pi*x)/L) x -1];
%%
%flexibility matrix
d1 = @(x) sqrt(1 + y_x_das(x).^2).*((Q_a(x)'.*Q_a(x))./(A_x(x)*E));
d1_x = d1(x)
%d1_int = integral(@(x)d1(x), 1E-8, 100., 'ArrayValued', 1)
d1_int = int(d1_x, 1e-8, 100)
vpa(d1_int)
Torsten
on 28 Oct 2022
@Milan question moved here:
Hello,
I got a 6*6 matrix in this format, how do I get this as a one single matrix?
[ 626.35, -97.77, -4756.45, -626.35, 97.77, -5020.31]
[ -97.77, 35.79, 2115.79, 97.77, -35.79, 1462.95]
[-4756.45, 2115.79, 142701.95, 4756.45, -2115.79, 68877.21]
[ -626.35, 97.77, 4756.45, 626.35, -97.77, 5020.31]
[ 97.77, -35.79, -2115.79, -97.77, 35.79, -1462.95]
[-5020.31, 1462.95, 68877.21, 5020.31, -1462.95, 77418.13]
Torsten
on 28 Oct 2022
The output might be written in this format - internally, it's a usual matrix.
Walter Roberson
on 28 Oct 2022
mat2str() will show it with just one []
Note: mat2str() may lose the bottom bit of numbers. format long g loses the bottom bit of numbers. If you need to be able to exactly reproduce the array then you will need to create your own function to convert it.
Answers (0)
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


