필터 지우기
필터 지우기

Dimensions of matrices being concatenated are not consistent.

조회 수: 1 (최근 30일)
sydney salvador
sydney salvador 2020년 3월 17일
댓글: Guillaume 2020년 3월 17일
fid=fopen('Data2.txt'); %will read notepad data
s=textscan(fid,'%f %f','headerlines',2); %variable "s" will show and plot data
g = cell2mat(s); %i have error here
x=g(:,1);
y=g(:,2);
[sortedX, sortIndex] = sort(x);
sortedY = y(sortIndex);
findpeaks(sortedYLimited,sortedXLimited,'MinPeakProminence',205,'Annotate','extents')
[psor,lsor] = findpeaks(sortedYLimited,sortedXLimited,'MinPeakProminence',205,'SortStr','descend')
i have this code but it doesnt work im trying to graph these data:
Data2.txt <-- this is notepad
5.000, 26.000
5.010, 28.000
5.020, 28.000
5.030, 39.000
5.040, 28.000
5.050, 37.000
5.060, 30.000
  댓글 수: 7
sydney salvador
sydney salvador 2020년 3월 17일
it might not be a cell, because it can be seen as a big table of 100 rows and 2 columns
Guillaume
Guillaume 2020년 3월 17일
Attaching the input file to the question would greatly help in understanding the problem.
What version of matlab are you on that you're still using texscan when a one-line readmatrix would probably import your file directly as a matrix.
g = readmatrix('Data2.txt'); %A much more meaningfull variable name than g would be a very good idea!

댓글을 달려면 로그인하십시오.

답변 (1개)

Sriram Tadavarty
Sriram Tadavarty 2020년 3월 17일
Hi,
I see that the issue is with usage of textscan function. Replace the line with this
s=textscan(fid,'%f, %f','headerlines',2); %variable "s" will show and plot data
For more details about usage of this function, go through https://www.mathworks.com/help/matlab/ref/textscan.html#btghhyz-5
Hope this helps.
Regards,
Sriram

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by