e422.m
来自「学习Matlab循环语句的好例子」· M 代码 · 共 43 行
M
43 行
% Script file:E422.m
% Purpose:
% Write a program that calculates and plots the number of bacteria present
% in each culture at intervals of 3 hours from the beginning of experiment
% until 24 hours have elapsed
% Record of revisions
% Date Programmer Descripton of changes
% ============= =============== ================================
% 13/06/08 ZMW Original Code
% Define Variables
% t ----------the time,hour as unit
% numA ----------bacteria A's number
% numB ----------bacteria B's number
% ii ---------the index
numA=ones(1,9);
numB=ones(1,9);
ii=1;
for t=0:3:24
numA(ii)=2^t;
numB(ii)=2^(2*t./3);
ii=ii+1;
end
t=0:3:24;
plot(t,numA,'b-');
hold on
plot(t,numB,'r-');
title('\bf t VS num(general plot)');
legend('numA','numB');
hold off
figure;
semilogy(t,numA,'b-');
hold on;
semilogy(t,numB,'r-');
title('\bf t VS num(semilogy plot)');
legend('numA','numB');
hold off
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?