Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

how to simplier this programme

3 visualizaciones (últimos 30 días)
nian
nian el 18 de Feb. de 2012
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by