필터 지우기
필터 지우기

how to calculate scalar with matrix

조회 수: 2 (최근 30일)
Kathleen
Kathleen 2024년 2월 8일
편집: VBBV 2024년 2월 8일
I need to code the following: I got to part b and I am unsure how to get a scalar in the code.
Goal: (b)
% chapter 2-1
clear; clc; close all
%% normal stress
fprintf('\n ====== Exercise 2.1 a=======\n\n')
tau = [-30 -20; -20 -40]; %2D stress tensor (Mpa)
theta = 10;
fhat = [sind(theta) , cosd(theta)];
nhat = [ cosd(theta) , -sind(theta)];
tnhat = tau * nhat.';
tn = nhat * tnhat %normal stress
%% shear stress
ts = fhat * tnhat
fprintf('\n ====== Exercise 2.1 a end=======\n\n')
%%
fprintf('\n ====== Exercise 2.1 b =======\n\n')
I = [1 0; 0 1];
det[-30-x -20; -20 -40-x] = 0
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
fprintf('\n ====== Exercise 2.1 b end=======\n\n')
  댓글 수: 2
VBBV
VBBV 2024년 2월 8일
편집: VBBV 2024년 2월 8일
Use the symbolic toolbox to declare the unknown variable. Then solve the determinant using solve function for the unknown
syms x
D = [-30-x -20; -20 -40-x];
S = det(D) % determinant
sol = solve(S==0,x)
VBBV
VBBV 2024년 2월 8일
편집: VBBV 2024년 2월 8일
syms lambda % define lambda as symbolic variable (eigen value)
tau = [-30 -20; -20 -40]; % shear stress
I = [1 0; 0 1]; % identity matrix
S = det(tau - I*lambda) % determinant of characteristic equation
S = 
sol = solve(S==0,lambda) % solve for eigen values
sol = 
double(vpa(sol))
ans = 2×1
-55.6155 -14.3845

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2024년 2월 8일
편집: Matt J 2024년 2월 8일
Don't see any reason why you'd have to reinvent eigendecomposition:
lambda=eig([-30,-20; -20 -40])
lambda = 2×1
-55.6155 -14.3845

카테고리

Help CenterFile Exchange에서 Stress and Strain에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by