Matlab 不理解cmd_data(ii)=cell2mat(textscan(char(data{i})(ALL_STRT(ii):(ALL_STRT(ii)和#x2B;4)),';%f';);完全
我需要从EnduroSat读取EPS,但是我很难理解命令行cmd_data(ii)=cell2mat(textscan(char(data{I})(ALL_STRT(ii):(ALL_STRT(ii)+4)),“%f”);Matlab 不理解cmd_data(ii)=cell2mat(textscan(char(data{i})(ALL_STRT(ii):(ALL_STRT(ii)和#x2B;4)),';%f';);完全,matlab,Matlab,我需要从EnduroSat读取EPS,但是我很难理解命令行cmd_data(ii)=cell2mat(textscan(char(data{I})(ALL_STRT(ii):(ALL_STRT(ii)+4)),“%f”); 我被要求使用MatLab进行编码,但这一行有错误,我不明白为什么。每当你在MatLab中看到这样一行复杂的代码时,试着将其分解 IND_STRT = 0; ALL_STRT = IND_STRT:12:510; cmd_data = zeros(length(ALL_STRT
我被要求使用MatLab进行编码,但这一行有错误,我不明白为什么。每当你在MatLab中看到这样一行复杂的代码时,试着将其分解
IND_STRT = 0;
ALL_STRT = IND_STRT:12:510;
cmd_data = zeros(length(ALL_STRT),1); %example: x=zeros(1,21) gives you a 1 by 21 matrix
for ii = 1:length(ALL_STRT) %declare variable ii to run from the row of length
if ~isempty(data{i})
cmd_data(ii) = cell2mat(textscan(char(data{i}(ALL_STRT(ii):(ALL_STRT(ii)+4))),'%f'));
end
end
您可以在其文档页面中特别阅读其中每一部分做得更好的内容,如果您在代码中添加断点,您可以看到它的工作情况,并且可以看到调用它时每个部分都输出了什么。了解如何调试,是一个非常强大的工具欢迎使用堆栈溢出!请拿起这本书,仔细阅读。唉,解释你从互联网上提取的代码不在本网站的范围之内。请询问此代码的作者,即要求您使用此代码的作者,或者阅读
cell2mat
、textscan
和char
的文档。
% find some indices. These values have been selected by the programmer/data, can't say why.
a=ALL_STRT(ii):(ALL_STRT(ii)+4)
% obtain that articular section of the data
b=data{i}(a)
% convert it to a char data type (characters)
c=char(b)
% scan text, and treat them as float
d=textscan(c,'%f')
% the output is a cell array, we want a matrix instead. Make the cell array into a matrix.
cmd_data(ii) = cell2mat(d)