Effacer les filtres
Effacer les filtres

write some statements on the command line to remove the largest elements from a vector .try it out on x=[1 2 5 0 5]. the idea is to end up with [1 2 0] in x. Use find and empty vector [ ].

1 vue (au cours des 30 derniers jours)
clc
clear
runflag='Y';
while runflag=='Y'|runflag=='y'
x_6 = input('Please input in the following format [a b c d n]: ');
vec=max(x_6);
vec1=find(x_6<vec);
vec2=x_6(vec1);
disp('New vector is: ');
disp(vec2);
runflag=input('Keep running [Y or N] :','s');
end

Réponses (1)

KSSV
KSSV le 22 Mar 2018
x=[1 2 5 0 5] ;
[val,idx] = sort(x) ;
pick how many you want from x

Catégories

En savoir plus sur Performance and Memory dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by