필터 지우기
필터 지우기

Simple question about functions

조회 수: 1 (최근 30일)
JP
JP 2013년 6월 21일
Hello, just a simple question about functions. What I want to do is use a function in main code, and create a new variable from within a structure. My main code reads
practicefcn()
x=data1.x;
My function reads
function [ data1,x ] = practicefcn()
data1.x=5;
data1.y=4;
end
This gives me an error. Hopefully you see what I want to do. I want to create a datastructure where x = 5 within that data structure, but also I want to create a separate variable where x = 5, defined outside of the data structure. Thanks!

채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 6월 21일
data1 = practicefcn();
x = data1.x;

추가 답변 (0개)

카테고리

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