I want to connect the IP-Cam (Axis P3905-R) to Matlab with the following script:
function readIPVideo()
cam = ipcam('http://192.168.13.125/mjpg/video.mjpg');%no login and password necessary
preview(cam);
closePreview(cam);
clear cam;
end
I get the following error-message:
"Error using readIPVideo (line 6)
Cannot connect to the IP Camera Stream URL. Make sure the URL is correct and authentication is provided if needed."
If I put the URL into a browser, there is a connection to IP-Cam as well as in VLC-Player. Why it doesn't work with Matlab? I'm using Matlab R2015a. The error occurs in Suse Linux Leap as well as in Windows 10.
Thanks for help,
Miriam
Related
I want to connect my Arduino to App Designer by using the "drop down" list. This is what my app looks like
First, I am looking for if there is any serial com. system. And I am writing them to Drop Down.
p = instrhwinfo('serial');
app.SerialPortsDropDown.Items = p.AvailableSerialPorts;
After this I have planned to read the serial port that is shown in the Drop Down and write it to serialport()
app.a = serialport(app.SerialPortsDropDown.value,9600);
Unfortunately these lines did not work. The error message I got:
Error using serialport (line 116)
Unable to connect to the serialport device at port 'COM9'. Verify that
a device is connected to the port, the port is not in use, and all
serialport input arguments and parameter values are supported by the
device.
So, the first two lines of code work. I am able to see COM9 (the com my arduino connected) in the drop-down list. This shows there is a serial port at COM9. But when it comes to reading it with app.a = serialport(app.SerialPortsDropDown.value,9600); it gives error.
How can I connect a serial port via the MATLAB App-designer?
app.a = serialport(app.SerialPortsDropDown.value,9600);
This is a wrong way of connecting Arduino to MATLAB. This declaration does not let us use Arduino functions such as 'writeDigitalPin, writePWMDutyCycle'.,
As I mentioned in the comments, it is still important to clear the port first and connect the serial port.
Lastly, the true way to declare Arduino to be able to use its functions as in the following:
app.a = arduino(app.SerialPortsDropDown.value, 'Tag of your arduino card');
I am running a code for my FPGA to collect data from accelerometer and I am able to print that to Tera Term. And I followed this tutorial to have MATLAB plot the data in real time.
I have essentially used the same code except a few changes in variable names title.
It gives me the following error.
The mathwork website has a similar question posted but there is no solution.
Open failed: Cannot connect to the COM6 port. Possible reasons are
another application is connected to the port or the port does not
exist.
Error in Untitled (line 8) fopen(s);
TIA
I'm trying to follow this guide on sending data from an arduino to a MATLAB program. I have every piece of code exactly matching the code in the example. However, whenever I attempt to start up the MATLAB program, I get the error message:
Error using serial/fopen (line 72) Open failed: Port: COM3 is not
available. Available ports: COM1. Use INSTRFIND to determine if other
instrument objects are connected to the requested device.
Error in Untitled8 (line 2) fopen(arduino)
Can anyone help me figure out how to get this working?
EDIT: My arduino is printing to COM3, so if I want MATLAB to hear it, it also needs to be COM3.
If I understand correctly you are using the Arduino IDE/Monitor to communicate with your Arduino on COM3. You want to have Matlab connect to the Arduino.
Since RS-232 is a point to point methology, you can only have one program/device on each end unless you add a bunch of hijinks.
When you have the Arduino IDE/Monitor open it uses the com port and other programs are denied access.
I think you need to close the Arduino monitor program to release Com port 3 and then the Matlab program should be able to open the port.
Problems:
I am able to use hyperterminal to send SMS via COM9. All good.
But I cannot properly use AT commands in matlab to do the same thing. I even cannot pass the first "AT" step. The error I received is "Unexpected Error: Unexpected Error: An error occurred during writing." It seems coming from fprintf. Help!
Here is the codes:
try
s = serial('COM9','BaudRate',9600);
fopen(s);
tx='AT';
tx1=char(13);
tx2=char(10);
fprintf(s, '%s', sprintf('%s%s%s', tx, tx1, tx2));
out = fscanf(s);
disp(out);
fclose(s);
catch aException
fclose(s);
error(message('MATLAB:serial:fprintf:opfailed', aException.message));
You have done the serial communication part properly. In AT command set, to check the working of the device it's enough if you send 'AT' and a line feed. Also you gave both carriage return and line feed to the device simultaneously. That could create a problem. Also while writing MATLAB code for the first time, try sending the characters individually as you do in Hyperterminal. It will solve your problem.
There will be no problem from MATLAB's perspective when the communication link is created successfully.
While connecting my Com-port using matlab, many a times(4 out of 5) I get an error
??? Error using ==> serial.fopen at 72
Port: COM21 is not available. Available ports: COM3,
COM10, COM17, COM18.
However , sometimes it gets connected and responds as expected.
Can anyone tell me whats the problem with this?
By the way , I am using this snippet to connect my microcontroller to PC through USB
s = serial('COM21'); // code to initialize the req COM i.e. COM21 for me
fopen(s);
I ran into this issue before. It turns out MATLAB doesn't really handle plug-and-play very well, as evidenced by this thread:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/311133
Long story short: if you want MATLAB to detect a hardware change, you need to restart it. MATLAB seems to only look for devices when it starts up.