필터 지우기
필터 지우기

How to name components of a vector to variables

조회 수: 4 (최근 30일)
Avenger2020
Avenger2020 2020년 11월 14일
댓글: Avenger2020 2020년 11월 14일
I need help naming my 21x1 matrix s to variables s0-s21. for example, s0=0, s1=0.05,........., s21=1 etc.
c is divided into N subintervals.
I'm not sure if naming them as variables is needed for what i want to achieve, but i want to calculate;
si = i*(c/N) ......eq1
and
si-1 = (i-1)*(c/N)
Please help in doing this the easiest way. See below for what i did so far
c=1;
N=20;
i=0:c:N;
s=(i)*(c/N)

답변 (1개)

James Tursa
James Tursa 2020년 11월 14일
Don't do that. Your downstream programming will be miserable if you do. See this link for better alternatives (cell arrays, structures, etc.)
  댓글 수: 1
Avenger2020
Avenger2020 2020년 11월 14일
Thank you. i just figured it out. i used the "diff" command which is alot more simplier than trying to write a code that does it.

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

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by