MATLAB Answers

Error: Unbalanced or unexpected parenthesis or bracket

5 ビュー (過去 30 日間)
Ricardo Henriques
Ricardo Henriques 2019 年 11 月 11 日
コメント済み: Walter Roberson 2019 年 11 月 13 日
The matlab show this error "Error: Unbalanced or unexpected parenthesis or bracket." in this part of the code:
%**************************************
nome = '105.txt';
[pathstr, name, ext] = fileparts(nome);
load(nome);
x=eval([name '(:,1)']);
y=eval([name '(:,2)']);
z=eval([name '(:,3)']);
%*************************************
---------------------------------------------------------------
105.txt contains 3 columns with several rows...
But on my friend's pc don't show this error... I have a Asus x64, with windows 10 and Matlab R2014b...
I think the problem is not from the code as it was functional on other pc's. I think it has to do with my compiler, but I don't know how to fix it ...
Already installed the version Matlab 6.5 R13, but the same error appears ...
What may be the source of this error?

  6 件のコメント

表示 3 件の古いコメント
Stephen Cobeldick
Stephen Cobeldick 2019 年 11 月 13 日
"I think the problem is not from the code ..."
In fact the problem is very badly designed code that relies on complex eval to generate invalid variable names. That code should be thrown away, it is never going to be reliable or efficient.
Ricardo Henriques
Ricardo Henriques 2019 年 11 月 13 日
So how should I replace the code?
Any suggestion?
Walter Roberson
Walter Roberson 2019 年 11 月 13 日
Steven Lord showed you.

サインイン to comment.

採用された回答

madhan ravi
madhan ravi 2019 年 11 月 11 日
I think name is variable, it's simply (there is no need for eval):
x = name(:,1);
y = name(:,2);
z = name(:,3);

  1 件のコメント

Ricardo Henriques
Ricardo Henriques 2019 年 11 月 11 日
The "name" came from of "[pathstr, name, ext] = fileparts(nome);"
The previous code is:
%********************************************
nome = '105.txt';
[pathstr, name, ext] = fileparts(nome);
load(nome);
x=eval([name '(:,1)']);
y=eval([name '(:,2)']);
z=eval([name '(:,3)']);
%***********************************************
105.txt contains 3 columns with several rows...

サインイン to comment.

その他の回答 (1 件)

サインイン してこの質問に回答します。


Translated by