フィルターのクリア

Matlab Mutiple Text Files, Plot

3 ビュー (過去 30 日間)
Matlab User
Matlab User 2016 年 8 月 19 日
編集済み: Matlab User 2016 年 8 月 29 日
can anyone please help me with this questions?
I plotted multiple files using the two while loops in the Matlab Editor --> run,but when I tried to plot the files using GUI pushbutton, I got this error message for some of the files..
Error using plot Vectors must be the same length.
fid= fopen([FilesToRead, MultipleFiles]);
Block=0;
while true
tLine = fgetl(fid);
if ~ischar(tLine)
break;
else
headerCells = strsplit(tLine,' ');
if length(headerCells) > 1
if ~isempty(headerCells{2})
if ~strcmpi(headerCells{2},'!user') && ~strcmpi(headerCells{2},'data')
textForGUI = headerCells{2}
end
end
end
end
if ~isempty(strfind(tLine,'data'))
Block=Block+1;
fprintf('\n\nBlock: %s\n\n', num2str(Block));
formatSpec = '%f %f %f %f %f';
C = textscan(fid,formatSpec,24,'CommentStyle','data','Delimiter','\t');
%here I got some calculations and plots
% I have for loop to handles indexing
end
end
end

採用された回答

Guillaume
Guillaume 2016 年 8 月 19 日
Well, the error message is very clear:
Error using plot. Vectors must be the same length
Error in [..] plot(Column4, CalcValue(:,1), '-rs');
Column4 and CalcValue(:, 1) are not the same length. That is the basic problem.
Note that if CalcValue has more than one column, then the line
Column4(end:end+numel(CalcValue)-numel(Column4))=nan;
is guaranteed to make Column4 longer than CalcValue(:, 1). Perhaps you meant:
Column4(end:end+size(CalcValue, 1)-numel(Column4))=nan; add as many nans as there are extra rows in CalcValue
  2 件のコメント
Matlab User
Matlab User 2016 年 8 月 19 日
編集済み: Matlab User 2016 年 8 月 29 日
it's not working.
Guillaume
Guillaume 2016 年 8 月 19 日
If all the plotted points are separated by nans, you would get only red squares:
xy = reshape([1:10; nan(1, 10)], 1, []) %values separated by nans
plot(xy, xy, '-rs')
I have no idea if that is your issue or not. Look at what's in CalcValue(:, 1) and Column4.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by