Matlab function outputs save in structure

9 ビュー (過去 30 日間)
cemsi888
cemsi888 2015 年 8 月 24 日
コメント済み: cemsi888 2015 年 8 月 24 日
Hi guys i have really simple question. Lets assume that ı have function with two outputs. In another m file ı would lıke to call thıs function and save outputs of this function seperately in structure. Is it possible? I tried it but ıt saves just first output two times in this structure. I will note simple example in order to explain better.
function[x,y]=myfunction(a,b,c)
x=a+b
y=x*c
In another m file ı will write for example
struct. (x)=myfunction(1,2,3)
struct.(y)=myfunction(1,2,3)
ın structure you will see x=3 y=3 instead of y=9
how can i save these variables in structure correctly??

採用された回答

Guillaume
Guillaume 2015 年 8 月 24 日
In each of your call, your only capturing the first return value of the function. You want to capture both:
[s.x, s.y] = myfunction(1, 2, 3)
  1 件のコメント
cemsi888
cemsi888 2015 年 8 月 24 日
Thanx a lot!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by