need help with warning
Afficher commentaires plus anciens
I am trying to do following which gives me warning and code does not execute any further. Please help resolve this
A = [91, 89, 90, 93, 95, 97]
A.switch1 = A <=91;
A.switch2 = A > 91,
I get following warning. How do i make it right? THanks
============================= Warning: Struct field assignment overwrites a value with class "double". See MATLAB R14SP2 Release Notes, Assigning Nonstructure Variables As Structures Displays Warning, for details.
Réponse acceptée
Plus de réponses (2)
Neesha
le 5 Nov 2013
0 votes
1 commentaire
Image Analyst
le 5 Nov 2013
Warnings do not stop code, only errors do. Please accept my answer if you have no more questions. Thanks.
Neil Caithness
le 2 Fév 2015
0 votes
From the latest release notes:
Assigning Structures to Nonstructures
Because of a bug, previous releases of MATLAB have allowed structure assignment to a nonempty nonstructure to overwrite the previous value. MATLAB continues to allow this in this release, but generates a warning message. In a future release, attempting this type of assignment will generate an error.
2 commentaires
Image Analyst
le 2 Fév 2015
Are you talking about the 2015a prerelease? Because this code generates no warning in R2014b:
% Create a non-empty variable "a" that is not a structure.
a=10;
% Create a structure, str.
str.field1 = 20;
str.field2 = 'abc';
% Now assign structure str to nonempty, nonstructure "a"
a = str; % No warning message.
Matthias Goldgruber
le 22 Déc 2015
You dont get a warning because you do something different!
Try the following:
a=10;
a.b=11;
Then you should get the same warning.
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!