Unknown Error

3 vues (au cours des 30 derniers jours)
Lukas
Lukas le 23 Avr 2012
EDU>> fid = csvread(uigetfile({'*.csv';'*.txt';'*.dat'}, 'Select the CV File'), 2, 1, 'eof');
??? Attempted to access range(3); index out of bounds because numel(range)=0.
Error in ==> dlmread at 108
if r > range(3) || c > range(4), result= []; return, end
Error in ==> csvread at 54
m=dlmread(filename, ',', r, c, rng);
The top is the line I am trying to execute and the bottom is the subsequent error message I am receiving. I have tried trouble shooting it myself but I am not sure what the problem is. Can anyone help?

Réponses (5)

Richard Brown
Richard Brown le 23 Avr 2012
The fourth argument to csvread should be a range, i.e. a vector with four entries. You have 'eof'. Try removing this argument and see if this fixes your problem.
  1 commentaire
Lukas
Lukas le 23 Avr 2012
EDU>> fid = csvread(uigetfile({'*.csv';'*.txt';'*.dat'}, 'Select the CV File'), 2, 1);
??? Error using ==> textscan
Mismatch between file and format string.
Trouble reading number from file (row 1, field 2) ==> C-V S
Error in ==> csvread at 52
m=dlmread(filename, ',', r, c);
That is the response I get. :(

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 23 Avr 2012
csvread() cannot be used for files that have text headers. Not even when you specify the row and column.
If you have text headers, use textscan() directly.
  4 commentaires
Lukas
Lukas le 27 Avr 2012
The response I get when I load the code
fid = fopen(uigetfile({'*.csv';'*.txt';'*.dat'}, 'Select the CV File'), 'rt');
Just in the command window I get fid=-1 meaning that it couldnt open the file correct?
Lukas
Lukas le 27 Avr 2012
...one add on to that, I get that response obviously after I have selected the file.

Connectez-vous pour commenter.


Lukas
Lukas le 24 Avr 2012
I also have tried using fopen directly
EDU>> fid = fopen('CV US Protocol_BD1726-54 1000ud1.csv')
fid =
3
EDU>> C = textscan(fid, 'r')
C =
Empty cell array: 1-by-0
To try and put the data into a cell array but as you can see, for some reason, the cell array is emtpy. Can anyone help me figure this out? Thanks

Lukas
Lukas le 24 Avr 2012
SetupTitle, CV US Protocol
PrimitiveTest, C-V Sweep
TestParameter, Channel.UnitTyp, CMU
TestParameter, Channel.Unit, CMU1:MF/SC
TestParameter, Channel.IName,
TestParameter, Channel.VName, VBias
TestParameter, Channel.Mode,
TestParameter, Channel.Func, VAR1
TestParameter, Channel.Index,
TestParameter, Channel.Time,
TestParameter, Measurement.Primary.Locus, Single
TestParameter, Measurement.Primary.Scale, LINEAR
TestParameter, Measurement.Primary.Start, -10
TestParameter, Measurement.Primary.Stop, 10
TestParameter, Measurement.Primary.Step, 0.1
TestParameter, Measurement.Aborting.Condition, CONTINUE AT ANY
TestParameter, Measurement.PostOutput.Value, START
TestParameter, Measurement.PostOutput.Retention, OFF
TestParameter, Measurement.Secondary.ACLevel, 0.03
TestParameter, Measurement.Secondary.FName, Freq
TestParameter, Measurement.Secondary.Frequency, 1000000, 100000, 10000, 1000
TestParameter, Measurement.Bias.Source, 0
TestParameter, Measurement.ImpedanceMode.Model, Cp-G
TestParameter, Measurement.ImpedanceMode.CName, C
*....... I cut out the whole header just to give you a portion of it but it is 200+ lines if strings (obviously asymmetric in columns) *
AnalysisSetup, Analysis.Setup.Vector.List.Datum.Name, VBias, C, G
AnalysisSetup, Analysis.Setup.Vector.List.Datum.Unit, V, F, S
AnalysisSetup, Analysis.Setup.Preference.GraphVisible, true
AnalysisSetup, Analysis.Setup.Preference.ListVisible, true
AnalysisSetup, Analysis.Setup.Preference.ScalarVisible, true
AnalysisSetup, Analysis.Setup.Title, CV US Protocol
Dimension1, 201, 201, 201
Dimension2, 4, 4, 4
DataName, VBias, C, G
DataValue, -10, 7.14698E-11, 7.31843E-06
DataValue, -9.9, 7.2232999999999992E-11, 3.75349E-06
DataValue, -9.8, 7.26777E-11, 5.50536E-06
DataValue, -9.7000000000000011, 7.28037E-11, 4.36322E-06
DataValue, -9.6, 7.33505E-11, 4.8255199999999995E-06
DataValue, -9.5, 7.37495E-11, 2.7934899999999997E-06
DataValue, -9.4, 7.36746E-11, 7.22263E-06
DataValue, -9.3, 7.46931E-11, 6.51808E-06
Anyway, there is a blank space line at the start that is not shown. I am interested in the frequencies listed on line 21 and then obviously the data on line listing 'DataValue'
Any help would be greatly appreciated. :)

Image Analyst
Image Analyst le 27 Avr 2012
csvread expects a bunch of numbers, not mixed numbers and text, and different numbers of things on each line, like you have:
AnalysisSetup, Analysis.Setup.Title, CV US Protocol
Dimension1, 201, 201, 201
Dimension2, 4, 4, 4
DataName, VBias, C, G
DataValue, -10, 7.14698E-11, 7.31843E-06
Since each line is so vastly different, you might have to read each line with fgetl() or fgets() and parse each line depending on what it looks like.
  3 commentaires
Image Analyst
Image Analyst le 27 Avr 2012
You can do that if you want. Read each line in one at a time like I said, parse it into things between the commas (you can use allwords for that http://www.mathworks.com/matlabcentral/fileexchange/27184-allwords) and then put those sentence fragments into cells.
Lukas
Lukas le 4 Mai 2012
Thanks, I will give it a try

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by