??? Error using ==> plot Invalid first data argument error

조회 수: 6 (최근 30일)
Mekala balaji
Mekala balaji 2014년 10월 31일
답변: Mekala balaji 2014년 10월 31일
I have the following code
for k=1:size(Desc,1) %Data_All{j}(i,1)=strcat(Desc{i}(1,:)); Data_All1{j}{k,1}=strcat(Desc{k}(1,:)); Data_All1{j}{k,2}=strcat(Dataopen{k}(1,:)); Data_All2{j}{k,1}=strsplit((Data_All1{j}{k,2}),' '); A{j}{k,1}=Data_All2{j}{k,1}; C3{j}{k,1}=A{j}{k,1}{2}; a1=C3{1}{1,1}; a2=C3{1}{1,1}; plot(a1,a2); Data_All1{j}{k,3}=strcat(Dataend{k}(1,:));
end
but i am getting ??? Error using ==> plot Invalid first data argument
can anyone help

채택된 답변

Geoff Hayes
Geoff Hayes 2014년 10월 31일
Mekala - please format the above code so that it is readable. Highlight the code and press the {} Code button.
As well, please describe what your inputs are. Desc and Dataopen appear to be cell array of strings. Is this the case? Where is j initialized? If I run the above code, will it reproduce the error message that you have provided?
Given your use of strcat, strsplit, and naming of the variable Desc (for description?) it would appear that all of your arrays are populated with strings. This would include a1 and a2 which are inputs to the plot function
plot(a1,a2);
If I try to pass strings (character arrays) to this function as
plot('hello','world');
then I observe the same error as you
Error using plot
Invalid first data argument
The error is appropriate. Is this what you are doing, and if so, what are you trying to plot?

추가 답변 (1개)

Mekala balaji
Mekala balaji 2014년 10월 31일
clc;clear all;
clc
tic
FileList=dir('D:\Matlab2010\Filesfolder\Code for files\Textfilesreference\fewfiles/');
j=1;
for i=3:1:(size(FileList))
FileName{j}=FileList(i).name;
j=j+1;
%disp(FileName);
end
% for i=1:size(FileName,2)
% FileDate{j} = FileName{j}(00:50);
% end
for j=1:size(FileName,2)
fin=fopen(['D:\Matlab2010\Filesfolder\Code for files\Textfilesreference\fewfiles/',FileName{j}],'r');
s=1;
while ~feof(fin)
tt=fgetl(fin); %Scan all lines
%fclose(fin);
%disp(FileName);
if s>=25 && s<=41
aa=(tt);
Desc{s-24,:}=strsplit(aa(1:47));
Dataopen{s-24,:}=strsplit(aa(50:65));
Dataend{s-24,:}=strsplit(aa(72:size(aa,2)));
end
s=s+1;
end
for k=1:size(Desc,1)
%Data_All{j}(i,1)=strcat(Desc{i}(1,:));
Data_All1{j}{k,1}=strcat(Desc{k}(1,:));
Data_All1{j}{k,2}=strcat(Dataopen{k}(1,:));
Data_All2{j}{k,1}=strsplit((Data_All1{j}{k,2}),' ');
A{j}{k,1}=Data_All2{j}{k,1};
C3{j}{k,1}=A{j}{k,1}{2};
C4{k}=strcat(C3{j});
C6{k}=str2num(C4{j});
%C5{j}{k,1}=strcat(C3{j}{k,1});
%C5{j}{k,1}=strcat(C3{j}{k,1});
% C6{j}{k,1}=str2num(C3{j}{k,1});
% C7{j}{k,1}=str2num(C3{j}{k,1});
%C6{j}{k,1}=str2num(C5{j}{k,1}); % C7{j}{k,1}=str2num(C3{j,1}); % plot(C6{j}{k,1},C7{j}{k,1}); Data_All1{j}{k,3}=strcat(Dataend{k}(1,:));
end
end
toc
if true
% code
end

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by