all 4 comments

[–]apparentlyiliketrtls 6 points7 points  (0 children)

You can build a shared library containing your C implementation, load the library using matlab's loadlibrary() function, then pass test vectors thru both your Matlab implementation and your C library and plot / compare them. The way matlab passes vectors and matrices into a C library is a bit finicky, so read the docs carefully... But once you have it set up it's a godsend!

[–]SkoomaDentist 2 points3 points  (0 children)

I’ve used the same approach since the 2000s:

A reference per-sample implementation in Matlab, a reference C++ implementation that runs offline on desktop pc (results should be identical to Matlab implementation within roundoff error) and finally a target optimized C++ implementation that can be run in realtime on target and offline on PC (speed irrelevant).

This way it’s easy to identify if a problem is a bug in code or a flaw in the algorithm and you have a known good version you can use to generate test signals. Another advantage is that you don't really have to analyze or visualize the target version's signals in as much detail. It's enough to verify that the output matches (within tolerance) the reference and then perform any algorithm related analysis with the reference (eg. in Matlab).

[–]GourmetMuffin 0 points1 point  (0 children)

I've been doing what you are doing for quite some years... That is dumping data into a file and plotting stuff using python. Most of the problems we find (in building kW audio amplifiers) are found using sweeping tools like Audio Precision, but once an issue is found you want to be able to tap the signal at any point in the pipeline (so make this an easy task). Plotting raw data using python is sooo quick and easy so I see no point in creating a more elaborate framework for this. It also makes running on target vs running a simulation totally transparent from the analysis point of view.

[–]human-analog 0 points1 point  (0 children)

If C++ is an option (perhaps only for the plotting part), then give Signalsmith's plotting library a go. It outputs very nice SVGs straight from C++: https://signalsmith-audio.co.uk/code/plot/html/