Why do I get an "Invalid value returned."-error when assigning a string property inside a loop using v18b?
Show older comments
When initializing an object of class "Matlab_Dbl_Str_Test" (class in attached file below) in Matlab v18b the result is the following:

When avoiding the try catch block one gets the above mentioned error.
It appears that properties of type string cannot be assigned in a loop whereas properties of type double are perfectly fine.
Is this a known bug or wanted feauture?
%% --------------------------------------------------------------------------
classdef Matlab_Dbl_Str_Test < handle
%UNTITLED2 Summary of this class goes here
% Detailed explanation goes here
properties( Constant )
TEST_STR = ["a";"b";"c"];
TEST_DBL = [0;1;2];
end
properties( SetAccess = protected )
test_str@string as vector;
test_dbl@double as vector;
end
methods
function obj = Matlab_Dbl_Str_Test()
for i = 1:3
try obj.test_str(i) = Matlab_Dbl_Str_Test.TEST_STR(i,1);end
try obj.test_dbl(i) = Matlab_Dbl_Str_Test.TEST_DBL(i,1);end
end
end
function test( obj )
for i = 1:3
try obj.test_str(i) = Matlab_Dbl_Str_Test.TEST_STR(i,1);end
try obj.test_dbl(i) = Matlab_Dbl_Str_Test.TEST_DBL(i,1);end
end
end
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Operations on Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!