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

1 visualización (últimos 30 días)
Mateja Sima
Mateja Sima el 28 de Jun. de 2022
Respondida: Walter Roberson el 28 de Jun. de 2022

Respuestas (2)

Walter Roberson
Walter Roberson el 28 de Jun. de 2022
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 el 28 de Jun. de 2022
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 ./.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by