simple code for the log computation

조회 수: 11 (최근 30일)
Tino
Tino 2019년 4월 25일
댓글: Star Strider 2019년 4월 25일
Hello,
Please can anyone help me with a short code to do the following computation below
X = { 1, 2, 3, 5, 6}
M1 = log10(X(:,1));
M2 = log10(X(:,2));
M3 = log10(X(:,3));
M4 = log10(X(:,4));
Thanks in advance
Tino

채택된 답변

Star Strider
Star Strider 2019년 4월 25일
Since ‘X’ is a cell array, you first must convert it to a double array, here using ‘[X{:}]’:
X = { 1, 2, 3, 5, 6};
M = log10([X{:}])
producing:
M =
0 0.3010 0.4771 0.6990 0.7782
Please do not name them ‘M1’...‘M4’. Keep them as a single array, and refer to them that way. If you want them to be individual elements of a cell array, use the num2cell function.
  댓글 수: 2
Tino
Tino 2019년 4월 25일
Thanks Star
Star Strider
Star Strider 2019년 4월 25일
My pleasure.

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

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2019년 4월 25일
X = [1, 2, 3, 5, 6];
M = log10(X);

카테고리

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

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by