Can't get an output from my function using loops
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Alec Burton
el 21 de Oct. de 2021
Respondida: Alec Burton
el 21 de Oct. de 2021
function resultData = enter_data(numTrials)
dataArray = cell(numTrials, 4);
iteration = 1;
while iteration <= numTrials
promptName = "Enter the name of trial: ";
getName = input(promptName, 's');
dataArray{iteration, 1} = getName;
promptMeasure1 = 'Enter first measurement: ';
getMeasure1 = input(promptMeasure1);
dataArray{iteration, 2} = getMeasure1;
promptMeasure2 = 'Enter second measurement: ';
getMeasure2 = input(promptMeasure2);
dataArray{iteration, 3} = getMeasure2;
promptMeasure3 = 'Enter third measurement: ';
getMeasure3 = input(promptMeasure3);
dataArray{iteration, 4} = getMeasure3;
iteration = iteration+1;
end
disp(dataArray);
resultData = dataArray;
end
I'm unable to get resultData as an output from this function. What am I doing wrong?
2 comentarios
Steven Lord
el 21 de Oct. de 2021
How are you calling the function? Please show us the exact call you made to enter_data.
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!