フィルターのクリア

How to solve this equation with two variables in one equation ?

60 ビュー (過去 30 日間)
Robert101
Robert101 2019 年 8 月 19 日
コメント済み: Adam Danz 2019 年 8 月 20 日
A = 1;
B = 1;
for n=0.0:0.1:1.0
for c = 0.0:0.1:1.0
c0 = 1.13e-4;
w = -A*(c-c0)^2*(n^4-3*n^2+2*n)+B.*(c-1)^2*n^2;
end
end

採用された回答

Adam Danz
Adam Danz 2019 年 8 月 20 日
編集済み: Adam Danz 2019 年 8 月 20 日
Loop through index values rather than a vector of values.
Store each iteration in w(n,c) and pre-allocate w with NaNs.
A = 1;
B = 1;
c0 = 1.13e-4;
% Vectors to loop through
nVec=0.0:0.1:1.0;
cVec = 0.0:0.1:1.0;
w = nan(numel(nVec),numel(cVec)); %pre-allocate with NaNs
% Loop through each element of nVec
for n=1:numel(nVec)
% Loop through each element of cVec
for c = 1:numel(cVec)
w(n,c) = -A*(cVec(c)-c0)^2*(nVec(n)^4-3*nVec(n)^2+2*nVec(n))+B.*(cVec(c)-1)^2*nVec(n)^2;
end
end
w(n,c) is the result for inputs nVec(n) and cVec(c)
  6 件のコメント
Robert101
Robert101 2019 年 8 月 20 日
Thanks man. You are great
Adam Danz
Adam Danz 2019 年 8 月 20 日
Glad I could help and learn along with ya!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by