필터 지우기
필터 지우기

a question of assigning the list elements

조회 수: 1 (최근 30일)
dcydhb dcydhb
dcydhb dcydhb 2018년 12월 20일
답변: madhan ravi 2018년 12월 20일
i just want to assign the
m(0)=1;
m(1)=1;
m(2)=1;
and get the sum of them,but when i assign them,the matlab can't get the answer,and why?
syms s1;
syms m(k);
syms z(k);
m(0)=1;
m(1)=1;
m(2)=1;
s1=symsum(m(k),k,0,2)

답변 (2개)

KSSV
KSSV 2018년 12월 20일
m = [1 1 1] ;
iwant = sum(m) ;
  댓글 수: 2
dcydhb dcydhb
dcydhb dcydhb 2018년 12월 20일
is there a way that we could use the form
m(0)=1;
m(1)=1;
m(2)=1;
oter than assign it in the matrix?
this form is convenient for the postprocess
KSSV
KSSV 2018년 12월 20일
Remember matlab index starts from 1...the index should be always positive.
m(0)=1;
m(1)=1;
m(2)=1;
The above is same as:
m = [1 1 1] ;
The above step is short, effective. You can access the elements using:
m(1)
m(2)
m(3)
MATLAB is very effificent and simple.

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


madhan ravi
madhan ravi 2018년 12월 20일
why? the below works because the right side should be a symbolic object to perform the operation you need
syms m(k)
m(k)=k
symsum(m(k),k,0,2)

카테고리

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

태그

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by