Assignment between unlike types is not allowed for two function in a loop
4 views (last 30 days)
Show older comments
hi, I converted the variables, S, V and D into struct, because I am using two criteria to evaluate, in the end the variable name is the same and I have to do a sum of those values, what should change (in Matlab I have the following error: Assignment between unlike types is not allowed) Is it possible to save them like this? or better I change the name of the variable as S1, S2 etc and at the end in my equation I add one by one.
For the first loop is working but after it finishes
%% Cracks
for i = 1:5
load([DataFolder '\' sprintf('beam_crack_%d.mat',i)]);
[S(i,:),V(i,:),D(i,:), n(i,:), Zi(i,:)] = bc_DE(beam_crack);
end
%% Spalling
for i = 1:5
load([DataFolder '\' sprintf('beam_spalling_%d.mat',i)]);
[S(i,:), V(i,:), D(i,:), n(i,:)] = bs_DE(beam_spalling);
end
In the function, one variable look like this
S.S1 = input('Input damage structural stability rate (S) (0-4) :');
while S.S1 <0 || S.S1 > 4
disp('Not a valid number please try again')
S.S1 = input('Enter a whole number between 0 and 4:');
end
0 Comments
Accepted Answer
Walter Roberson
on 28 Jul 2021
It looks like your function is returning struct variables.
When you have code of the form
struct1(index) = struct2
where struct1 is a structure, then that will fail if struct2 is []. It will also fail if struct2 has a different set of fields than struct1 has. Furthermore it will fail if all of the fields are the same but the fields are in a different order.
More Answers (0)
See Also
Categories
Find more on Structures 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!