Filter löschen
Filter löschen

How to stop this error from occurring every time I try to open a function or script in matlab?

21 Ansichten (letzte 30 Tage)
I have a script that I am trying to open in matlab (just open, not run) and MATLAB gives me an error when I attempt to open the file. The only way I have been able to resolve this so far is by deleting matlab from my mac and reinstalling it but that is getting annoying. It happens randomly as far as I can tell and it currently happens whenever I try to open any matlab files. The file name is resSimProj.m This is the error I get every time I try to open it:
Error: File: unique.m Line: 1 Column: 1
Invalid text character. Check for unsupported symbol, invisible character, or pasting of non-ASCII characters.
Error in setdiff>setdiffR2012a (line 226)
c = unique(c,order);
Error in setdiff (line 111)
[varargout{1:nlhs}] = setdiffR2012a(varargin{:});
Error in matlab.internal.lang.capability.Capability.Unsupported (line 74)
list = setdiff(capabilityArray, current);
Error in matlab.internal.lang.capability.Capability.require (line 85)
missingRequirements = matlab.internal.lang.capability.Capability.Unsupported(capabilityArray);
Error in uiopen (line 58)
Capability.require(Capability.Swing);
  1 Kommentar
Dyuman Joshi
Dyuman Joshi am 1 Nov. 2023
Bearbeitet: Dyuman Joshi am 1 Nov. 2023
I have bolded an important part of the problem description.
Seems like something is corrupted, given that you encounter the error on just opening the file.
However, that should be cleared when you re-install MATLAB completely. But, it still reoccurs. Weird.
Could you share the file that you are trying to open i.e. resSimProj.m ?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Les Beckham
Les Beckham am 1 Nov. 2023
Please enter the following command in the Command Window and make sure that the output looks similar to that shown here (all of the results are in subfolders of .../MATLAB/toolbox or ...\MATLAB\...). If you see any that aren't part of the Matlab installation, rename to something other than unique.m.
which -all unique
/MATLAB/toolbox/matlab/ops/unique.m /MATLAB/toolbox/matlab/ops/@cell/unique.m % cell method /MATLAB/toolbox/matlab/datatypes/categorical/@categorical/unique.m % categorical method /MATLAB/toolbox/matlab/datatypes/tabular/@tabular/unique.m % tabular method /MATLAB/toolbox/matlab/datatypes/datetime/@datetime/unique.m % datetime method /MATLAB/toolbox/matlab/datatypes/duration/@duration/unique.m % duration method /MATLAB/toolbox/matlab/bigdata/@tall/unique.m % tall method /MATLAB/toolbox/matlab/datatypes/calendarDuration/@calendarDuration/unique.m % calendarDuration method /MATLAB/toolbox/parallel/gpu/@gpuArray/unique.m % gpuArray method /MATLAB/toolbox/parallel/parallel/@codistributed/unique.m % codistributed method /MATLAB/toolbox/shared/statslib/@dataset/unique.m % dataset method /MATLAB/toolbox/symbolic/symbolic/@sym/unique.m % sym method /MATLAB/toolbox/symbolic/symbolic/@symfun/unique.m % symfun method
  4 Kommentare
Steven Lord
Steven Lord am 1 Nov. 2023
Also can you show the output of these commands?
dbtype 1 unique.m
1 function varargout = unique(tA, varargin)
L = readlines("unique.m");
D = double(char(L(1)))
D = 1×37
102 117 110 99 116 105 111 110 32 118 97 114 97 114 103 111 117 116 32 61 32 117 110 105 113 117 101 40 118 97
I'm guessing you may have accidentally typed something as the first character in unique.m in which case the first number in the vector D will be different than 102 (the character 'f' in 'function').
Dyuman Joshi
Dyuman Joshi am 1 Nov. 2023
@Steven Lord, But how will modifying unique.m result in an error when opening the file?
Shouldn't the file open without any errors?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by