Difference in File Referencing

4 views (last 30 days)
Richard Prince
Richard Prince on 6 Feb 2019
Commented: Richard Prince on 6 Feb 2019
If I have some function that takes as input the path to two files and an integer, what is difference in the following two situations?
Case 1: function("file1.tif", "file2.tif", N)
Case 2: function('file1.tif', 'file2.tif', N)
If I run my code using case two, I get an error about brace indexing later on in the code. Whereas, if I run case 1 it works fine.

Accepted Answer

TADA
TADA on 6 Feb 2019
Without the Code We Can Only Speculate. But Using "File1.Tif'" generates A String Object While 'File1.Tif' Is A Character Array.
When You Index The String Array Like That:
s = stringObj(1)
You Get A String
And If You Index A Character Array Like That:
c = charVector(1)
You Get A Single Character
See The Documentation Characters and strings
  1 Comment
Richard Prince
Richard Prince on 6 Feb 2019
Thank you! That explains if perfectly. I didn't include the code as I was more interested in the syntactic difference than the exact specific of this error.

Sign in to comment.

More Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!