How to do +,-,*,/ with one scalar and one matrix(IN GUI)?
조회 수: 1 (최근 30일)
이전 댓글 표시
답변 (2개)
Walter Roberson
2022년 6월 28일
str2double always returns a scalar when the input is a character vector or character array. It only returns a matrix if the input is a string array or a cell array of character vectors.
We cannot tell what handles.matrica refers to. If it refers to a uicontrol style 'edit' then if you set the 'Maximum' property to more than 1, then the String property could be a cell array of character vectors that is a column vector, in which case each row would have its character vector processed, returning one scalar per row.
If you have multiple entries in the same row of a uicontrol 'edit' then str2double is going to return nan for the row.
If you want the user to enter a 2d array of numbers, use a uitable()
댓글 수: 0
Benjamin Thompson
2022년 6월 28일
Addition and subtraction are the same. You can add or subtract a scalar from a matrix. Adding or subtracting matrices requires they have the same size.
If you are trying to multiple matrices (of same size) as a series of scalar multiplications instead of traditional matrix multiplication, use the .* operator. Use ./ for division, and .^ to raise all the elements of a matrix by a scalar exponent.
You can multiple or divide a matrix by a scalar using *, /, or .* or ./.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!