Fopen: Invalid Parameter List

15 visualizzazioni (ultimi 30 giorni)
Würzfleisch
Würzfleisch il 14 Set 2018
Commentato: Walter Roberson il 15 Set 2018
Dear Community,
I've got the error message: "Invalid parameter list" from my function, which let MatLab open a text file and read it to get input data for my work.
Here is the code:
function [machNumbers, weights, altitudes, specificRanges]=readsrm(RYR378W6.txt)
fid = fopen('RYR378W6.txt','w');
fskipl(fid, 3);
# read number of machnumber
numMachNumber = fscanf(fid, "%i", 1)
fscanf(fid, "%s", 5);
machNumbers = fscanf(fid, "%f", numMachNumber);
# read weights
numWeights = fscanf(fid, "%i", 1);
fscanf(fid, "%s", 5);
weights = fscanf(fid, "%f", numWeights)
# rad altitudes
numFl = fscanf(fid, "%i", 1)
fscanf(fid, "%s", 5);
altitudes = fscanf(fid, "%f", numFl)
irrelevantValues = fscanf(fid, "%s", 7)
for flightLevel= 1:numFl
for weight = 1:numWeights
specificRanges(flightLevel, weight, 1:numMachNumber) = fscanf(fid, "%f", numMachNumber);
endfor
endfor
fclose(fid);
endfunction
Maybe some of you see my fault.
I would welcome your help.
All the best,
Michael
  1 Commento
Walter Roberson
Walter Roberson il 15 Set 2018
Please do not close questions that have an answer.

Accedi per commentare.

Risposte (1)

Rik
Rik il 14 Set 2018
There may be more errors (please include your file so we can check), but at the very least you should use fopen with the read permission, instead of the write permission.
Also, you shouldn't use the Octave-only syntax on this forum. We will help you to get it to work with Matlab, but in general you should look elsewhere for Octave advice. Although in my mind they aren't, most people see Matlab and Octave as competing products, and this website is run by Mathworks.
  1 Commento
Walter Roberson
Walter Roberson il 14 Set 2018
fskipl is not a MATLAB function, and it is also not present in the File Exchange. There appears to be an Octave function by that name.
The syntax
function [machNumbers, weights, altitudes, specificRanges]=readsrm(RYR378W6.txt)
is not valid MATLAB. MATLAB requires that the part in () be a list of items each of which are valid variable names or else the symbol ~ . It is never valid in MATLAB to have a structure field reference or object property reference or object method reference in a function header. (It is also not valid to have a quoted string in a function header.)
"#" is not a valid MATLAB comment marker.
There is no MATLAB function named endfunction and there is nothing in the File Exchange by that name either.
"most people see Matlab and Octave as competing products"
The Free Software Foundation tells me that it is more or less morally evil to want to retain copyright to some portion of my code, that I have an obligation to give away all software I write. I disagree firmly: I have a right to have boundaries on what I can be obliged to do for other people. I give away or refuse to give away my software on my own terms, not because I am required to. And among other things, retaining copyright permits me to refuse permission for my software to be used for things I morally and ethically disagree with, such as weapons work. Technology is never really value-neutral.
So while I am grateful to the long efforts of people who have chosen to give away use of software such as gcc, I choose not to contribute to an organization (FSF) as their philosophy can feel emotionally abusive if taken seriously.
And that means I choose not to work with Octave.

Accedi per commentare.

Categorie

Scopri di più su Data Acquisition Toolbox Supported Hardware in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by