This question maybe silly,I am new to matlab. I have two variables, lets say a and b, I want to create a new variable which's value is a_b; how can I do it?

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 6월 15일
편집: Azzi Abdelmalek 2016년 6월 15일

0 개 추천

I don't know what is your aim by doing this, but it seems it's a bad idea
Star Strider
Star Strider 2016년 6월 15일

0 개 추천

Just call it ‘a_b’.
For example:
a_b = a + b;
As a general rule, it is best to use numeric or cell arrays to name what might be best considered to be elements of arrays (so ‘c(k)’ or ‘c{k}’ is the correct way to create a new variable as part of an array, and ‘c_k’ is quite definitely not the correct way), variables are best named to be as descriptive as possible.
For example:
mean_a_b = mean(a.*b);
is better than:
a_b = mean(a.*b);

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2016년 6월 15일

답변:

2016년 6월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by