Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
how to simplier this programme
조회 수: 3 (최근 30일)
이전 댓글 표시
Please help me to make this programme more simple. I have done this programme but my prof want it to be more simple. I tried to make it simple but it goes wrong. I think this is simple to me but not my prof… if you can help me, please do.. thanks.. this is the question.. To determine the highest, lowest and the average value of two vectors depending on user own choice by mean of MATLAB Programming.. and below this, the command that I’ve make..
close all
clear all
clc
disp('Welcome to my program.');
disp(' ');
disp('instruction:');
disp(' a ) Enter the number of column of a vector.');
disp(' b ) Next, enter the element for vector A and vector B.');
disp(' c ) Then, select your option of what do you want to find.');
disp(' ');
column = input (' Enter the number of column of a vector: ');
disp(' ')
disp(' Enter the element for vector A ');
for count=1:column
disp(['A (',num2str(count), ')=']);
A(count)=input(' ');
end
disp(' ')
disp(' Enter the element for vector B');
for count=1:column
disp(['B(',num2str(count),')=']);
B(count)=input(' ');
end
disp(' ')
disp(['Vector A is [',num2str(A),')']);
disp(['Vector B is [',num2str(B),')']);
disp(' ')
disp('What do you want to find?');
disp(' ')
disp('1-find the highest value');
disp('2-find the lowest value');
disp('3-find the average value');
choose=input('Choose:');
disp(' ')
while choose >3
disp('Sorry, please enter the right input!');
choose=input('choose:');
end
disp('Your result:')
disp(' ')
fprintf('number of column:%2.0f\n',column);
disp(['vector A:[',num2str(A),']']);
disp(['vector B:[',num2str(B),']']);
if choose ==1
disp('choice: find the highest value');
elseif choose==2
disp('choice: find the lowest value');
elseif choose==3
disp('choice: find the average value');
end
switch choose
case 1
A = max(A);
B = max(B);
result=max(A,B);
case 2
A = min (A);
B = min (B);
result=min(A,B);
case 3
A = mean (A);
B = mean (B);
end
disp(['Vector A:',num2str(A)]);
disp(['Vector B:',num2str(B)]);
if choose==1
disp(['the highest value: ',num2str(result),'']);
else if choose==2
disp(['the lowest value:',num2str(result),'']);
end
end
댓글 수: 0
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!