Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

i need help writing a function!

1 visualización (últimos 30 días)
Kevin Smith
Kevin Smith el 18 de Oct. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I am trying to write a function that looks like this
function update(student, field,value)
I need it to allow me to input a student structure into the command window like this:
>> test_student=struct('name','Kevin L. Smith','gpa', 3.71,'standing' true)
And then allows me to update the value for any given field in the command window. For example if this is entered:
updated_student=update(test_student,'name','Kevin L. Sams')
the output would be:
updated_student=
name: 'Kevin L. Sams'
gpa: 3.71
standing: 1
I have been trying to figure this out for hours and do not even have any script or codes to show for it! I am having a lot of trouble with this one.

Respuestas (1)

Walter Roberson
Walter Roberson el 18 de Oct. de 2017
function student = update(student, field, value)
student = setfield(student, field, value);

La pregunta está cerrada.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by