Invalid expression in reading the file
Ältere Kommentare anzeigen
function [rR,CL,effi1] = import_cl_effi(general_data,16, 45);
%IMPORTFILE1 Import numeric data from a text file as column vectors.
% [RR,CL,EFFI1] = IMPORTFILE1(FILENAME) Reads data from text file
% FILENAME for the default selection.
%
% [RR,CL,EFFI1] = IMPORTFILE1(FILENAME, STARTROW, ENDROW) Reads data from
% rows STARTROW through ENDROW of text file FILENAME
%% Initialize variables.
delimiter = ' ';
if nargin<=2
startRow = 16;
endRow = 45;
end
%% Format string for each line of text:
% column2: double (%f)
% column5: double (%f)
% column9: double (%f)
% For more information, see the TEXTSCAN documentation.
formatSpec = '%*s%f%*s%*s%f%*s%*s%*s%f%*s%*s%[^\n\r]';
%% Open the text file.
fileID = fopen('general_data.txt','r');
%% Read columns of data according to format string.
% This call is based on the structure of the file used to generate this
% code. If an error occurs for a different file, try regenerating the code
% from the Import Tool.
textscan(fileID, '%[^\n\r]', startRow(1)-1, 'ReturnOnError', false);
dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'MultipleDelimsAsOne', true, 'EmptyValue' ,0.0,'ReturnOnError', false);
for block=2:length(startRow)
frewind(fileID);
textscan(fileID, '%[^\n\r]', startRow(block)-1, 'ReturnOnError', false);
dataArrayBlock = textscan(fileID, formatSpec, endRow(block)-startRow(block)+1, 'Delimiter', delimiter, 'MultipleDelimsAsOne', true, 'EmptyValue' ,0.0,'ReturnOnError', false);
for col=1:length(dataArray)
dataArray{col} = [dataArray{col};dataArrayBlock{col}];
end
end
%% Close the text file.
fclose(fileID);
%% Allocate imported array to column variable names
rR = dataArray{:, 1};
CL = dataArray{:, 2};
effi1 = dataArray{:, 3};
I am getting following error
Error: File: import_cl_effi.m Line: 1 Column: 54
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax
error. To construct matrices, use brackets instead of parentheses.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Simulink Environment Customization finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!