필터 지우기
필터 지우기

How to store double value in a matrix

조회 수: 19 (최근 30일)
Mausmi Verma
Mausmi Verma 2022년 2월 9일
답변: Walter Roberson 2022년 2월 9일
I have a variable as
A <1x3 double> = 1 9 3
I want to store it in a predefined matrix B and want answer to look like
B=4 [193] 6
Dimension of B is 1x3
i am trying but getting error as "Subscripted assignment dimension mismatch."
please help

답변 (1개)

Walter Roberson
Walter Roberson 2022년 2월 9일
temp = sum(A.*(10.^(length(A)-1:-1:0)))
B(2) = temp;
This is under the assumption that you want to take the digits of the individual array elements and use them to create a single decimal number to be stored.
If instead you want the second element of B to become the vector of values so that when you index B(2) you get back the vector as distinct elements, then that cannot be done with a numeric array, and you would have to use a cell array instead.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by