Effacer les filtres
Effacer les filtres

Return a phrase based on a matrix entry

1 vue (au cours des 30 derniers jours)
Luke Brunot
Luke Brunot le 2 Nov 2018
Commenté : madhan ravi le 3 Nov 2018
Hello,
I have pasted my code below. I have another excel file that this program is reading from that contains matrix entries. What I would like to accomplish is:
If a matrix entry in column 3, for example, is less than a certain number, then I want MatLab to display a phrase.
I would like it to check multiple columns and see if any entries are less than numbers of my choice and display a phrase. If you could get me started, I would really appreciate it!
clear
clc
%clears workspaceand command window
a = csvread('Computers1.csv');
%loads in data set from excel
column1 = a(:, 1);
column2 = a(:, 2);
column3 = a(:, 3);
column4 = a(:, 4);
count=1;
while count<=61
if column3<
y=('reduce prices by 10%');
disp(y)
count=count+1;
elseif column3<40
z=('reduce prices by 20%');
disp(z)
count=count+1;
end
count=count+1;
end
  1 commentaire
madhan ravi
madhan ravi le 3 Nov 2018
@Geoffrey i suggest to move your comment to answer section so that Luke could accept your answer

Connectez-vous pour commenter.

Réponses (1)

Geoffrey Schivre
Geoffrey Schivre le 3 Nov 2018
Hello,
I'm not sure to understand well your question but if you want that matlab display your phrase if there is at least one value below your number use something like this
if any(yourColumn < yourNumber)
disp(['your phrase'])
end

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by