필터 지우기
필터 지우기

coding for algebric equations

조회 수: 1 (최근 30일)
PK
PK 2012년 9월 5일
I am stuck in coding a algebric equation Y=exp[1+∑_(j=1)^2▒〖[[Aj-Ajexp(1-∑_(i=0)^10▒〖Bij*Xi)〗〗/1- exp^2 (1-∑_(i=0)^10▒〖Bij*Xi)〗]
A,B,X are some random matrices and for some reference the code below can be considered and i want to know how to remove the complex part of an exponential to subtract it from a constant as in the numerator of above equn
%
clc
clear all
close all
NI=2;
NH=10;
B=randint(NI,NH,[1,20])
i=1:NI
j=1:NH
% i(1,1),i(1,2)
A=randint(10,1,[1,10])
A(1,1)
x=[1 2]
c=x*B
C=1-sum(c)
exp(C)
d=A*expm1(c)
f=sum(d)
real(f)
square(exp(c))
%
  댓글 수: 2
Star Strider
Star Strider 2012년 9월 5일
I ran your code (replacing i by k1 and j by k2 even though you do not use them anywhere) and replacing randint (that does not exist in 2012a) with randi (that does), and:
c=x*b
with:
c=x'*B'
because you cannot multiply [1 x 2] vector x by [10 x 1] vector B.
I did not get any complex numbers in any result.
Please do not use i and j as variables! MATLAB uses these for its imaginary operators, and while they will work as index variables, they will also cause endless confusion if you also have complex numbers in your calculations.
PK
PK 2012년 9월 6일
if you can see a equation in the post and the code is only a part of it any suggestions how it can be solved completely

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Call C++ from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by