필터 지우기
필터 지우기

How to use variables in a matrix?

조회 수: 3 (최근 30일)
Yusuke Nakamura
Yusuke Nakamura 2016년 4월 14일
편집: Andrei Bobrov 2016년 4월 14일
Hi.
I was looking for the way to use a variable inside a matrix, and found some resources which explain the method using syms and subs function. However, my matlab code gives an output in fraction for each element of the matrix. Could you please tell me how I can fix this issue? (matlab code is attached)
Thanks in advance.

답변 (2개)

Andrei Bobrov
Andrei Bobrov 2016년 4월 14일
편집: Andrei Bobrov 2016년 4월 14일
Qc = [176.7308, 2.7786, 0;
2.7786, 11.3413, 0;
0, 0, 4.1991];
func1 = @(h)sum(Qc(:)*diff(h*(-2:2)),2);
A = reshape(func1(1),size(Qc));
for your case:
func1 = @(h)4*Qc*h;
A = func1(1);

Stalin Samuel
Stalin Samuel 2016년 4월 14일
Replace line no 11 to
A = double(subs(A,h,1))

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by