Hi Everyone. Ive created a set of questions for user to select the material characteristics based on their preferences and need help to choose best results best on their ans
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Muhammad Ammar Fiqri Bin Johari Johari
il 28 Dic 2022
Commentato: Muhammad Ammar Fiqri Bin Johari Johari
il 30 Dic 2022
Below is the coding. i want to show user which material between is the best based on average answer. Kindly need your help.
x=input('enter required strength /10 =');
if x>0 && x<=5
save ('AS')
save ('AA')
elseif x>5 && x<=8
save ('PL')
elseif x>8 && x<=10
save ('PC')
end
t=input('choose hardness 75/80/90/100 =');
if t==75
save('PL')
elseif t==80
save('PC')
elseif t==90
save('AA')
elseif t==100
save('AS')
end
reply=input('enter expected finishing low-med-high : ','s');
if strcmp(reply,'low')
save('AS')
elseif strcmp(reply,'med')
save('PC and PL')
elseif strcmp(reply,'high')
save('AA')
end
4 Commenti
Rik
il 30 Dic 2022
And how would you solve this with pen and paper? Would you have some sort of points system so at the end you can select the option with the most points?
You need to do something in each branch that you can keep track of. Presumably that is what you intended with the save calls. The save calls resulted in the creation of mat files. What could you replace that with? Based on a set of answers, how do you want to determine the best?
Risposta accettata
Karim
il 30 Dic 2022
Hi, see below for some possibilities on how to code such selection.
% material options
Materials = ["AS";"AA";"PL";"PC"];
Strength = zeros(numel(Materials),1);
Hardness = zeros(numel(Materials),1);
Finishing = zeros(numel(Materials),1);
SelectionTable = table(Materials,Strength,Hardness,Finishing);
% get user input
% Strength = input('enter required strength /10 =');
% Hardness = input('choose hardness 75/80/90/100 =');
% Finishing = input('enter expected finishing low-med-high : ','s');
% user inputs is not possible online, hence pick some random results:
Strength = 4;
Hardness = 80;
Finishing = 'med';
% logic for the strength
if Strength>0 && Strength<=5
SelectionTable.Strength([1,2]) = 1;
elseif Strength>5 && x<=Strength
SelectionTable.Strength(3) = 1;
elseif Strength>8 && Strength<=10
SelectionTable.Strength(4) = 1;
end
switch Hardness
case 75; SelectionTable.Hardness(3) = 1;
case 80; SelectionTable.Hardness(4) = 1;
case 90; SelectionTable.Hardness(2) = 1;
case 100; SelectionTable.Hardness(1) = 1;
end
switch lower(Finishing)
case 'low'; SelectionTable.Finishing(1) = 1;
case 'med'; SelectionTable.Finishing([3,4]) = 1;
case 'high'; SelectionTable.Finishing(2) = 1;
end
% print the final selection table, this gives an overview of the material
% possibilities based on the user choises and the selection logic
SelectionTable
% to make a suggestion, we could pick the material that has the most 1's:
Suggestion = sum(SelectionTable{:,2:end},2)
[~,materialIdx] = max(Suggestion)
fprintf('Based on the user inputs, the recommended material is %s \n',SelectionTable{materialIdx,1})
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!