Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How do I use variables calculated in one function, in another function.

3 ビュー (過去 30 日間)
Michael cornman
Michael cornman 2016 年 7 月 6 日
閉鎖済み: Stephen23 2016 年 7 月 6 日
I have the first .m file
function [Properties] = readProperties(FEA)
%Reads the material properties about the beam
format shorteng
Properties= fscanf(FEA,'%*s %*s %*s %g %g %g',[3,1])'
end
it reads in 3 numeric values into an array called "Properties"
function [] = assembleGlobalStiffnessMatrix(Properties)
% Sets up Stiffness Matrix
Properties
end
In this separate .m file, how can I get that variable, "Properties", to show. Right now it just gives an error saying that "Properties" doesn't exist.
My assignment specifies that the use of global variables is prohibited if that makes a difference.

回答 (1 件)

KSSV
KSSV 2016 年 7 月 6 日
In the first function readProperties, you are reading the properties of your structure in an array. According to the command it reads three numbers. After running this file, have you checked what is output properties? Is it a array with three numbers? If it is array then, depending on your order in file FEA fed to first function, your values would be.
property1 = properties(1) ;
property2 = properties(2) ;
property3 = properties(3) ;
The above should be used in your second function to assemble stiffness matrix.
  4 件のコメント
Michael cornman
Michael cornman 2016 年 7 月 6 日
There is a parent function reading the nested functions cronologically.
Michael cornman
Michael cornman 2016 年 7 月 6 日
Chronologically*

この質問は閉じられています。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by