MATLAB Answers

Serial Communication Code Error

조회 수: 1(최근 30일)
Tobias Wzl
Tobias Wzl 24 Oct 2017
for i= 1:length(h)
I developed this code on friday for finding out on which Port my Arduino is plugged in and it actually worked. Today I tried to implement the code into my GUI and an error is appearing.
Error: Struct contents reference from a non-struct array object.
What do I have to do, so that the error won't appear anymore?
Thank you for your help

  댓글 수: 0

댓글을 달려면 로그인하십시오.


Nate 26 Oct 2017
Hi Tobias,
Could you please provide more information?
1) Does the code still work correctly when it is not in a GUI? 2) Could you please provide the full error? I am interested in knowing which line causes the error.
Thanks, Nate

  댓글 수: 1

Tobias Wzl
Tobias Wzl 27 Oct 2017
No unfortunately not, but in first place it worked in both ways I don't know what's wrong now.
If run the code separate outside of a GUI the error appears in line 6:
*Struct contents reference from a non-struct array object.
Error in Untitled (line 6) str=string(;*

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 27 Oct 2017
You would get that error if instrfindall returns empty.

  댓글 수: 8

표시 이전 댓글 수: 5
Walter Roberson
Walter Roberson 27 Oct 2017
What is returned if you execute
Also, try
Tobias Wzl
Tobias Wzl 3 Nov 2017
if I execute the first command an empty answer appears --> ans=[]
if I execute the second command Matlab tells me that the function is undefined
And sorry for the late answer I was ill for the last whole week
Walter Roberson
Walter Roberson 3 Nov 2017
Hmmm, instrreset has been around in Instrument Control Toolbox since before R2006a;
Anyhow, I do not know why your devices cannot be seen, unless perhaps the system considers them to already be in use for something else. Perhaps this link will help:

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by