Struct contents reference from a non-struct array object (.mat)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi.. i have a neural network matrix (net.mat) and i want to send the valuse via serial to my MCU.. whenever i start my matlab code, then an errors pops up..Struct contents reference from a non-struct array object, line 2..
i cant get it, i am loading the project and loading the .mat in workspace.. but i still get that error..any Help? thanks
CODE:
function flash_send_weights(net, port)
s = size(net.hidden_layer_weights);
s2 = size(net.output_layer_weights);
fclose(instrfind);
ser = serial(com_port);
%set(ser, 'BaudRate', 38400);
fopen(ser);
page_size = 528;
byte_num = -4;
clc
fprintf('SERIAL PORT OPEN\n\n');
fprintf('Sending hidden layer matrix values to serial.\n\n');
for node=1:s(2)
for wt=1:s(1)
% send as its value * 1000000 (6 digits of precision)
% will need to convert back on other end
fprintf('|');
fprintf(ser,'%d\r', round(1000000*net.hidden_layer_weights(wt,node)));
byte_num = byte_num+4;
if(byte_num == page_size)
pause(1);
byte_num = 0;
end
pause(0.05);
end
fprintf('\nWeights for node %d sent.\n', node);
end
pause(3);
fprintf('\nSending output layer matrix values to serial.\n\n');
for node=1:s2(2)
for wt=1:s2(1)
% send as its value * 1000000 (6 digits of precision)
% will need to convert back on other end
fprintf('|');
fprintf(ser,'%d\r', round(1000000*net.output_layer_weights(wt,node)));
if(byte_num == page_size)
pause(1);
byte_num = 0;
end
pause(0.05);
end
fprintf('\nWeights for node %d sent.\n', node);
end
% send extra value. (For some reason the other end needs this)
fprintf(ser,'1234567\r');
fclose(ser);
printf('Complete!\n');
end
0 commentaires
Réponses (1)
Star Strider
le 22 Août 2016
See if using the Layer addressing will work. See specifically Access Layers and Properties in a Layer Array.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!