How to do +,-,*,/ with one scalar and one matrix(IN GUI)?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1048975/image.png)
0 commentaires
Réponses (2)
Walter Roberson
le 28 Juin 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()
0 commentaires
Benjamin Thompson
le 28 Juin 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 ./.
0 commentaires
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!