Functions for structure array

조회 수: 3 (최근 30일)
Matheus
Matheus 2014년 9월 10일
답변: Matt J 2014년 9월 10일
I get how to many a structure array in the command window but I am kind of lost of how to write the function for it. Mostly the function header. I need to make a structure of students that have the inputs of name, id, and grades. I need to have a 1x1 structure of newStudents and then populate a 1x5 stucture of students.
would it be correct to write
function [student] = student
student = [student,newStudent];
and then fill it? Please help

답변 (1개)

Matt J
Matt J 2014년 9월 10일
There are a few ways. Here is the most direct,
>> student=struct('name',{'George','Mary','Steve','Susan','Ralph'},'grade',{'A','A+','F','A-','B'})
student =
1x5 struct array with fields:
name
grade

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by