Return a phrase based on a matrix entry
4 views (last 30 days)
Show older comments
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 Comment
madhan ravi
on 3 Nov 2018
@Geoffrey i suggest to move your comment to answer section so that Luke could accept your answer
Answers (1)
Geoffrey Schivre
on 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
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!