Since you are starting with MATLAB code you will probably want to use the MATLAB Function block in Simulink. This will be more straightforward to get working than reimplementing your algorithm using Simulink blocks. The first step will be to separate your testbench code (uigetfile, xlsread, etc.) from your design code and place only the design code in the function block. Then, to make 'weight' a register you will need to make it a persistent variable in the function block.
Additionally: while Simulink HDL Coder supports doubles for code generation, they in general are not synthesizable. You will probably want to convert your code to use fixed-point arithmetic if you want to synthesize your design.
The Simulink HDL Coder demo "An 8-bit RISC Processor using MATLAB Function Blocks" is a good place to start understanding the use of the MATLAB Function block for HDL code generation.