⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 repeat4.m

📁 《精通matlab7》“mastering matlab 7”的代码。
💻 M
字号:
% repeat4.m
% repeated value creation and counting
% inverse operation

%y = [3 3 0 0 0 5 6 6]; % data to examine

x = y(1);              % beginning data
n = 1;                 % beginning count
idx = 1;               % index value
for i=2:length(y)
   if y(i)==x(idx)     % value matches current x
      
      n(idx) = n(idx)+1; % increment current count
      
   else                % new value found
      
      idx = idx+1;       % increment index
      x(idx) = y(i);     % poke in new x
      n(idx) = 1;        % start new count
   end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -