compare results of m-file and simulink processing
1 view (last 30 days)
Show older comments
Hi I built up an m-file that multiplies a vector twice with itself (elementwise) and with its conjugate complex version and a simple constant. The same I did in Simulink
When I compare the results by subtracting the vector generated by the m-file from the vector generated by the simulink counterpart I get a difference (error) about 1.0e-07 which is of course small.
But this is only one stage of the whole thing I am planning to do and the error sums up.
Are m-files and Simulink simulations using different engines or rounding modes? Why am I getting this errors, since both of them should use double.
This is the m-file
global H_2
H_2 = complex(2);
load('random_test_data');
Stop_Time = length(v_raw_test_sig)-1;
struct_test_sig = create_simulink_sig(v_raw_test_sig);
o_simulink_sim = sim('fck_test','StopTime',num2str(Stop_Time));
struct_test_out = o_simulink_sim.get('struct_test_out');
test_out = struct_test_out.signals.values;
vc_dpd = fck_test_fcn(struct_test_sig.signals.values);
1 Comment
Kaustubha Govind
on 6 May 2011
What is the datatype of the test data? How are you importing it into the Simulink model (this is important because Simulink may interpolate the data unless you provide data samples for every time-step that it runs when using something like the From Workspace block). I know that libraries used for some algorithms are different between MATLAB and Simulink, but I'm not sure that a simple multiplication operation would yield a difference. Note that most Simulink Math blocks allow you to configure the saturation and rounding modes.
Answers (1)
12312dsfafasd
on 9 May 2011
1 Comment
Kaustubha Govind
on 9 May 2011
When you construct the data for the From Workspace block - do you specify the "time" vector? If yes, does this coincide exactly with the 'tout' signal that is logged to the workspace at the end of simulation?
You mentioned that using integer data, the results from MATLAB and Simulink match. Did you mean that you just use real(v_raw_test_sig) to construct the data, or do you also convert it to int using int32(real(v_raw_test_sig))?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!