How to append fields of a structure from different/many script file?

1 回表示 (過去 30 日間)
Anil Kamat
Anil Kamat 2020 年 1 月 19 日
編集済み: Image Analyst 2020 年 1 月 19 日
Hi there,
I am trying to append field value of a structure from a different script file than the structure was created in. But unfortunately its not working. Following is the code that I am trying with. Any suggestion is appriciated. Thanks!
  1. First script
clc;clear all;
network.node = zeros(5);
network.node(1,:) = 7;
mode = zeros(5,1);
for i = 2:5
mode(i,:) = app(network,i);
end
2. Second Script
function mode = app(network,i)
mode = i;
nod = network.node;
nod(i,:) = i;
network.node = nod;
end

採用された回答

Image Analyst
Image Analyst 2020 年 1 月 19 日
編集済み: Image Analyst 2020 年 1 月 19 日
If you want network to have the "node" field you modified inside of the app() function, then you need to return network from the function:
function [mode, network] = app(network, i)
mode = i;
nod = network.node;
nod(i, :) = i;
network.node = nod;
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by