How to do +,-,*,/ with one scalar and one matrix(IN GUI)?

1 回表示 (過去 30 日間)
Mateja Sima
Mateja Sima 2022 年 6 月 28 日
回答済み: Walter Roberson 2022 年 6 月 28 日

回答 (2 件)

Walter Roberson
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()

Benjamin Thompson
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 ./.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by