多语言展示
当前在线:414今日阅读:155今日分享:35

怎么在matlab中进行逻辑判断?

学习和分享。
工具/原料
1

电脑

2

matlab软件

方法/步骤
1

if ~isempty(get(groot,'CurrentFigure'))     %如果现有的窗口没有图disp('There are existing figures.')         %显示There are existing figureselse    disp('There are no existing figures.')   %显示There are no existing figuresend

2

if ~isempty(findobj('Tag','myFigures'))        disp('There are objects with this tag.')              %显示There are objects with this tagelse        disp('There are no objects with this tag.')            %显示There are no objects with this tagend

3

if isgraphics(h,'figure')      disp('h is a valid figure handle.')else      disp('h is not a valid figure handle.')end

4

if isequal(h,groot)      disp('h is the root handle')else      disp('h is not the root handle')end

5

p = plot(magic(3)); par = get(p,'Parent'); objarray = [par{:}]'; whos objarray

6

p1 = plot(1:10); p2 = p1; p2 == p1

7

l1 = line; l2 = line; isequal(l1,l2)

8

t = num2str(rand); fh = @(t) text(1,1,t); th = cellfun(fh,{t},'UniformOutput',false);

推荐信息