Solving Function in MATLAB App Designer

8 ビュー (過去 30 日間)
Rachel McMurphy
Rachel McMurphy 2019 年 10 月 27 日
コメント済み: Steven Lord 2023 年 11 月 6 日
I have an app with 5 Edit Field (text) and 2 sliders (values from 1 - 12), and a 'solve' button. When the solve button is pressed, it must compute for the empty text field with the other 4 texts and the sliders.
Here is my code for the function used, where P_pY and C_pY are the slider values:
tvm = @(N, R, PV, PMT, FV, P_pY, C_pY) ...
(PV + 100 * PMT * C_pY / R) * (1 + R / (100 * C_pY))^(N * C_pY / P_pY) ...
- 100 * PMT * C_pY / R + FV;
For example, if N=180, R=6, PV=100000, FV=0, P_pY=12, and C_pY=12, then PMT should come back as -843.8568.
I've tried 'if'' loops but always wind up with an error and my professor made no sense when he was trying to help us in class.
  2 件のコメント
Nada
Nada 2023 年 11 月 6 日
Write a function that takes as an input a number ‘n’ and returns a vector containing n numbers of the Fibonacci sequence. Assume that the input n is an integer equal to or greater than 2. Run the function for inputs: 2, 7 and 9. Recall: The Fibonacci sequence follows the trend n(the base i)=n(the base i-1)+n(the base I-2) Hint: Use if statements to generate the vector if the sequence is 1 or 2 numbers long. (Example of Fibonacci sequence: 0,1,1,2,3,5.....)
Steven Lord
Steven Lord 2023 年 11 月 6 日
You should ask this as a separate question, not as a comment on an unrelated question. When you do, since this sounds like a homework assignment, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the free MATLAB Onramp tutorial to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.

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

回答 (2 件)

Walter Roberson
Walter Roberson 2019 年 10 月 27 日
N = app.N.Value;
R = app.R.Value;
PV = app.PV.Value;
and so on
if isempty(N)
app.N.Value = fzero(@(N) tvm(N, R, PV, PMT< GV, P_PY, C_pY), rand());
elseif isempty(R)
app.R.Value = fzero(@(R) tvm(N, R, PV, PMT< GV, P_PY, C_pY), rand());
end

alfiya riyas
alfiya riyas 2019 年 12 月 17 日
  • >> SOM
  • Not enough input arguments.
  • Error in SOM (line 19)
  • X=X';
function [IDX, C]=SOM(X,NetSize)
X=X';
nSample=size(X,2);
pTrain=0.1;
nTrain=round(pTrain*nSample);
XTrain=X(:,randperm(nSample));
XTrain=XTrain(:,1:nTrain);
% Create a Self-Organizing Map
net = selforgmap(NetSize);
% Train the Network
net = train(net,XTrain);
% Create Outputs
y = net(X);
IDX=vec2ind(y);
% Get Centers
C=net.IW{1};
end
  1 件のコメント
Walter Roberson
Walter Roberson 2019 年 12 月 17 日
When you invoke SOM with no parameters, where are you expecting SOM to find the content for the variables X and NetSize ?

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

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by