MATLAB Answers

Disp: "Dot indexing is not supported for variables of this type"

조회 수: 6(최근 30일)
Hi,
So I was running the below code and I keep getting the message:
"char object
Properties:
Dot indexing is not supported for variables of this type.
Error in disp (line 34)
name=visible(name,object.ConcealedProperties);
Error in PlotSpecAndHistory (line 7)
disp('SELECT SPECTROGRAM BINARY FILE');"
So to read on disp I used the help function in the command window and then received a similar error, as I assume help also uses disp. Does anyone have any knowledge of why this might be happening? Thanks!
Edit: This same error also occurs when calling 'plot'
% start fresh
close all; clear; clc
% Choose the Spectogram file using a GUI
disp('SELECT SPECTROGRAM BINARY FILE');
[SFile,SPath] = uigetfile('*','Select Spectrogram Binary File','Spectrogram.mat');
if isequal(SFile,0)
disp('SPECTROGRAM: User selected Cancel');
else
disp(['SPECTROGRAM: User selected "', fullfile(SPath,SFile) '"']);
end
% Choose the History file using a GUI
disp('SELECT HISTORY TEXT FILE');
[HFile,HPath] = uigetfile('*','Select History File','History.txt');
if isequal(HFile,0)
disp('HISTORY: User selected Cancel');
else
disp(['HISTORY: User selected "', fullfile(HPath,HFile) '"']);
end
load([SPath SFile])
Hist = dlmread([HPath HFile],'',27,0);
X_Hist = Hist(:,1);
Y_Hist = Hist(:,2);
% check if the data is in velocity or frequency
% if data is in frequency (large), then convert using user input
if max(Y_Spec)>1e8
prompt = {'Enter Laser Wavelength (nm):'};
dlgtitle = 'Convert Frequency to Velocity';
dims = [1 30];
definput = {'1550'};
temp = inputdlg(prompt,dlgtitle,dims,definput);
LaserWavelengthS = eval(temp{1});
clear temp
% Convert to m/s
Y_Spec = Y_Spec.*(LaserWavelengthS/2)./1e9;
else
disp('Spectrogram velocity format was read as m/s');
end
if max(Y_Hist)>2500
prompt = {'Enter Laser Wavelength (nm):'};
dlgtitle = 'Convert Frequency to Velocity';
dims = [1 30];
definput = {'1550'};
temp = inputdlg(prompt,dlgtitle,dims,definput);
LaserWavelengthH = eval(temp{1});
clear temp
Y_Hist = Y_Hist.*(LaserWavelengthH/2)./1e9;
else
disp('History velocity format was read as m/s');
end
% Convert time axes to microseconds
if max(X_Spec)<1
X_Spec = X_Spec.*1e6;
else
disp('Spectrogram time format was read as mus');
end
if max(X_Hist)<1
X_Hist = X_Hist.*1e6;
else
disp('History time format was read as mus');
end
% PLOT IT ALL UP
figure;
imagesc(X_Spec,Y_Spec,Z_Spec);
colormap(jet);
caxis([-60 0]);
set(gca,'YDir','normal');
hold on
plot(X_Hist,smooth(Y_Hist),'color','k','LineStyle','-','LineWidth',0.5);
xlabel('Time (\mus)')
ylabel('Velocity (m/s)')
C = colorbar;
C.Label.String = 'Intensity (arb)';
C.FontSize = 12;
axis([min(X_Hist) max(X_Hist) min(Y_Hist) max(Y_Hist)])
hold off
set(gca,'FontSize',12)
set(gcf,'PaperUnits','inches')
set(gcf,'PaperPosition',[0 0 4 3])
print([HPath HFile(1:(end-4)) '.png'],'-dpng','-r600');
disp(['Spectrogram and History Image written as' HPath HFile(1:(end-4)) '.png']);
% Make a grayscale compatible version (also for colorblind people)
figure;
imagesc(X_Spec,Y_Spec,Z_Spec);
colormap(flip(morgenstemning));
caxis([-60 0]);
set(gca,'YDir','normal');
hold on
plot(X_Hist,Y_Hist,'color','k','LineStyle','-','LineWidth',0.5);
xlabel('Time (\mus)')
ylabel('Velocity (m/s)')
C = colorbar;
C.Label.String = 'Intensity (arb)';
C.FontSize = 12;
axis([min(X_Hist) max(X_Hist) min(Y_Hist) max(Y_Hist)+1200])
hold off
set(gca,'FontSize',12)
set(gcf,'PaperUnits','inches')
set(gcf,'PaperPosition',[0 0 4 3])
print([HPath HFile(1:(end-4)) '.png'],'-dpng','-r600');
disp(['Grayscale Compatible Spectrogram and History Image written as' HPath HFile(1:(end-4)) 'Morgenstemning.png']);

  댓글 수: 0

로그인 to comment.

채택된 답변

Steven Lord
Steven Lord 14 Jan 2020
You've written or downloaded a disp.m file that's shadowing the built-in disp function. Run this code.
which -all disp
You will see a lot of entries, most of which are in MathWorks toolboxes (overloads of the disp function for specific object types.) If it says "% <something> method" at the end of the line, you can probably safely ignore it.
Look up near the top and you'll see one that doesn't belong (isn't a method of a class and isn't the built-in version.) Rename or remove that file.
Since you say you also received the same problem calling plot, you probably also have a plot.m that's shadowing the built-in plot function. The solution is the same, except you use plot in place of disp in the which call:
which -all plot
If those shadowing functions are in the same directory, you may want to look at the rest of the directory and remove or move that directory off the MATLAB search path.

  댓글 수: 1

로그인 to comment.

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.

태그

제품


릴리스

R2019a

Translated by