Return a phrase based on a matrix entry

1 次查看(过去 30 天)
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 个评论
madhan ravi
madhan ravi 2018-11-3
@Geoffrey i suggest to move your comment to answer section so that Luke could accept your answer

请先登录,再进行评论。

回答(1 个)

Geoffrey Schivre
Geoffrey Schivre 2018-11-3
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

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by