fopen syntax, a new usage???

1 Ansicht (letzte 30 Tage)
jason lee
jason lee am 13 Jul. 2020
Kommentiert: jason lee am 13 Jul. 2020
i found a usage of fopen which is not found in MATLAB documentations
here is my code
s = 'name';
fileID = fopen([s,'.txt'],'w');
this syntax really works. but i could not found the source.
the ordinary usage of fopen could be
fileID = fopen('name.txt','w')
why?
is MATLAB documentation uncomplete?
thank you!
  1 Kommentar
Stephen23
Stephen23 am 13 Jul. 2020
Bearbeitet: Stephen23 am 13 Jul. 2020
"but i could not found the source."
Did you try reading the source that I gave in your earlier question?
"is MATLAB documentation uncomplete?"
No. Just because you combined several commands and could not find that specific combination of commands in the documentation does not mean that the documentation is "uncomplete". Lets try another example: here are some commands that I combined just now:
pow2(sqrt(mode([9,9,4,1])))
Will we find that combination in the MATLAB documentation? I very much doubt it. Does this mean that the MATLAB documentation is "uncomplete" ? No, it does not. It means the user needs to look up each of those commands separately, understand how they work, and undertand how the combination works. This is exactly the same for all programming languages.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

madhan ravi
madhan ravi am 13 Jul. 2020
It’s not so complicated [] is used for concatenation
['name', '.txt'] % try it in command window and see what happens
  6 Kommentare
Walter Roberson
Walter Roberson am 13 Jul. 2020
Only for obtuse meanings of "required"
In the case of using command syntax instead of function syntax, then if an argument has whitespace or semi-colon or comma in it, then you need to use apostrophes (I seem to remember some cases where double-quotes did not do the trick, but I have not re-tested that in a couple of releases.)
jason lee
jason lee am 13 Jul. 2020
yes, thank you all.
as Walter Roberson says '...including a variable that holds the file name.'
that's everything that i need.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by