フィルターのクリア

Return a phrase based on a matrix entry

1 回表示 (過去 30 日間)
Luke Brunot
Luke Brunot 2018 年 11 月 2 日
コメント済み: madhan ravi 2018 年 11 月 3 日
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
  1 件のコメント
madhan ravi
madhan ravi 2018 年 11 月 3 日
+1 neat

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by