Return a phrase based on a matrix entry

4 visualizaciones (últimos 30 días)
Luke Brunot
Luke Brunot el 2 de Nov. de 2018
Comentada: madhan ravi el 3 de Nov. de 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 comentario
madhan ravi
madhan ravi el 3 de Nov. de 2018
@Geoffrey i suggest to move your comment to answer section so that Luke could accept your answer

Iniciar sesión para comentar.

Respuestas (1)

Geoffrey Schivre
Geoffrey Schivre el 3 de Nov. de 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

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by