I want to make a biometric identification system of the ECG/EKG.
Provided that Matlab does not perform Data Acquisition in Real Time (for monitoring), is there any way to make the monitoring and data acquisition in LabVIEW and then work simultaneously with Matlab for signal processing?
You could just get a matlab compatible daq and run everything in matlab. http://www.mathworks.com/products/daq/
You can indeed do some data acquisition with LabView and work simultaneously with Matlab for signal processing by calling the Matlab script node, which executes some Matlab code during vi execution.
You may have some performance issues, though, because both Labview and Matlab have to run on your machine simultaneously.
Question:
is there any way to make the monitoring and data acquisition on
LabView and then work simultaneously with Matlab for signal processing
Answers:
LabVIEW has "MathScript" node which is basic MatLab built into
an add-on. It is not the MatLab toolboxes. It runs native MatLab
code. It also runs slightly faster LabVIEW updates to the code. If
your code runs there, then LabVIEW will pass data natively
to your code. This box does not have direct MatLab toolbox access, so if
you use any special calls then that can cause a problem.
If you have MatLab on the box, then you can call the external MatLab
function/code using mathscript (link), and the MatLab will run
the function.
Clarification:
Real time just means "bounded time" (link), not "instant". If your idea of bounds are loose enough then many systems can work for them. You do not state it in your question - but what do you consider acceptable response time?
I've worked a lot with LabVIEW and Matlab. Personally, I would not use the Math Scripting node and would opt for using the Matlab Automation Server. You can call Matlab from LabVIEW using the ActiveX palette in LabVIEW (See Functions>>Connectivity>>ActiveX>>Automation Open) A couple reasons why I'd go for ActiveX and NOT the MathScript node:
The Math Script node does not allow you to change code dynamically. You must hardcode your data into the Math Script node and any future changes would require a change to LabVIEW's G code and therefore a recompile of your EXE
The Math Script node does not support all functions when compiled to an executable. Most notably graphing functions. See the help file here to read more on this.
Calling Matlab from ActiveX is going to give you a lot more flexibility in regards to how data is passed and processed.
Related
I was wondering if it is possible to use simlink's PID architecture in matlab to actually control hardware - rather than modelling it.
I have been playing around a little with the PID tuning in matlab - and have worked out the correct gains for my system (or at least good enough).
Now I want to implement the actual control loop in matlab using the real hardware. In this case I am tying to stabilise a laser using a measurement from a wavemeter - although from the point of view of matlab essentially I have two functions - one which returns the current wavelength, and another which alters the wavelength with an input from 0-100.
How do I get the fancy PID objects to work in a loop where for example I input data each loop, and get the required output to stabilise things given my gains - or should I just hardcode the equations in?
I have tried looking through some of the simlink examples - but there doesn't seem to me much actual implementation - mostly just modelling.
Thanks in advance for any advice.
MATLAB (without Simulink, or with Simulink in purely a simulation mode) is not a real-time environment. Trying to use it to control hardware in real-time won't work unless you have very slow sample rates.
If you do have slow sample rates, then you'd connect to your hardware to MATLAB using device drivers such as those in the Data Acquisition Toolbox
You haven't found any info on real-time implementation in the Simulink documentation because from Simulink the mechanism for real-time implementation is via Simulink Coder. You would need to use it in conjunction with a real-time environment such as Simulink Desktop Real-Time (if your sample rates are relatively slow), Simulink Real-Time, or one of many other 3rd party real-time form factors.
I've read that I can generate code from Simulink models/block diagrams. I am curious whether Simulink always converts a model to (c/c++/java) code prior to running a simulation in the Simulink software, and then execute that code? I mean, whenever I'm running a simulation is Matlab converting the block diagram to (c/c++/java) code and running that code behind the scene. In this case, simulation in Simulink directly depends on running some code; this information is important to me in some way.
Generating and running code for a complete model seems plausible, as we can write s-functions using C/Matlab code and use them as custom blocks. So simulating a model involves running code in some degree. Again, since we can write Matlab code as well, simulation may involve interpreting Matlab code in some environment. It makes me curious whether these information are available - how tightly running a simulation in Simulink depends on executing native code in user's machine.
I did some search before posting and found this SO question: How does simulation engine work? Discussion in this question does not answer my question directly.
The answer depens on which mode you chose.
In the normal mode Simulink will run the model as it is primarily using the MATLAB execution engine. No code is generated. Native implemented parts (e.g. S-Functions) are used as individual binaries called by the MATLAB interpreter.
In the accelerator mode Simulink generates model code. This means your full model (except parts where code generation is impossible) is generated and compiled into one binary.
In the rapid accelerator mode not only your model but also the solver is generated and compiled into one binary, now running in a separate process.
For more details refer to the official documentation
I'm trying to use a gui time-frequency toolbox in Matlab, but i can't find the proper function for one specific option and everytime I have to run it manually (using the gui form for calling the option)
The toolbox name is TFSA 6.3 from:
http://time-frequency.net/tf/index.php?option=com_content&view=category&layout=blog&id=38&Itemid=48
I am trying to use the LS polynomial coefficients algorithm in IF estimation tool. I know you may say that I need to read the user manual and find the right function in order to call it in the middle of program. trust me, I did it and there was nothing about this particular option.
I need to know if there is a way for using this gui toolbox without using the graphical interface, for example saving the history of my clicks...
One more thing! All the toolbox files are protected and I can't open them.
I have two systems running on MATLAB: the control system and the computer vision system.
The control system needs to receive three variables generated by the computer vision system periodically. However, I can't single thread both systems, because the computer vision system latency is too high compared with the control system latency.
I tried to run each program in a different MATLAB session and use a .mat file as interface between both sessions, but it did not work.
I'm not familiar with the Parallel Computing Toolbox. So I was wondering if someone can help with this? Or at lest give a start up idea, because, as I've said, I will start to learn the Parallel Computing Toolbox now.
I think the function in the Parallel Computing Toolbox you may be looking for is parfeval. It lets you spawn an asynchronous task, and get its result whenever it is ready.
In addition to parfeval as suggested by #Dima you might also want to look into labSendReceive
and associated function like labSend and labReceive which allow to share data between individual workers in your parallel pool. I guess which one is best for you depends on the type of calculation you want to do.
Is there anything I can do with code in MATLAB for digital image processing that I can't do with Simulink's digital image processing toolbox or vice versa?
What difference is there between the two?
At the code level, there's not much difference between MATLAB and Simulink. Simulink provides an environment for constructing programs at a higher level of abstraction than text; the relationships that hold between code blocks is represented as arrows that pass between flowchart objects. You can then visualize the system as it operates at runtime, as data objects are passed visibly between the flowchart blocks. Simulink also lets you alter a part of the program in real time, so that you can see the effects of the local change without having to stop everything else.
Given how much image processing work is done in block-level dataflow languages such as LabVIEW, I would recommend starting with Simulink. Most industrial or creative image processing (like Apple's Shake) is done via a node-based interface. That's not to say that you couldn't use MATLAB code as well; it's just a bit more obtuse (this is a good example of a powerful library that was made with MATLAB code).