現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
Index problem help?
5 ビュー (過去 30 日間)
古いコメントを表示
JL555
2015 年 9 月 22 日
for i=1:n
for j=1:n
Pl=P(i)*B(i)(j)*P(j);
seems like i'm getting error with writing B(i)(j)...How will i code it in another way?
採用された回答
Guillaume
2015 年 9 月 22 日
編集済み: Guillaume
2015 年 9 月 22 日
Possibly, you meant to write
Pl(i,j) = P(i)*B(i,j)*P(j)
Or possibly, you meant something else entirely. It's impossible to tell with so little information.
Most likely also, the loops are not needed and it can all be done with matrix operations.
17 件のコメント
Walter Roberson
2015 年 9 月 22 日
You vectorized your code and you did not show us the new code. We can't tell you what needs to be fixed.
JL555
2015 年 9 月 22 日
Pi=x(1:m,1:n1);
for i=1:n
for j=1:n
if pmin<Pi;
pmin=Pi;
else if Pi<pmax;
Pi=pmax;
C=Pi(i)*B(i,j)*Pi(j);
C1=B0(i)*Pi(i);
Pl=C+C1+Boo;
Pi=Pd+Pl;
end
end
end
end
Walter Roberson
2015 年 9 月 22 日
That code will not generate the error message you indicate.
Why did you not follow the conversation in http://www.mathworks.com/matlabcentral/answers/241944-using-summation-and-modulus
Note that you are doing a test of one vector compared to another. You would get a matrix dimensions must agree error there but not an inner dimensions must agree error.
If you were to switch so the two vectors are the same orientation then you face the problem that the test
if A < B
means the same as
if all(A < B)
and is only true if the comparison holds for every item in the vector.
JL555
2015 年 9 月 22 日
Actually the link to that answer is not valid anymore something terribly wrong with that program and i have a new one.And yes i'm getting a matrix dimension must agree ...so it is not possible to use the 'lt' to generate a matrix of 1x6 or should i compare with only one elemnt of that matrix?
Walter Roberson
2015 年 9 月 22 日
It is obvious to me from the code that you should be rewriting using matrix algebra. But every time I fix your code for you, you change it completely and look like you have not understood anything I wrote. You also do not answer questions about what size of output you are expecting from each step. It leaves me reluctant to assist.
JL555
2015 年 9 月 22 日
編集済み: Walter Roberson
2015 年 9 月 22 日
function [Ft Pi Pl]=FPAeld(x)
global objfun data pmin pmax Pd B B0 Boo
n=length(data(:,1));
[m n1]=size(x);
Pi=x(1:m,1:n1);
for i=1:n
for j=1:n
if data(1,4)<Pi;
data(1,4)=Pi;
else if Pi<data(1,5);
Pi=data(1,5);
C=Pi(i)*B(i,j)*Pi(j);
C1=B0(i)*Pi(i);
Pl=C+C1+Boo;
Pi=Pd+Pl;
end
end
end
end
a=data(:,1);
b=data(:,2);
c=data(:,3);
e=data(:,6);
f=data(:,7);
for i=1:n,
Pi=[Pi Pi(i)];
Ft=a(i)+b(i)*Pi(i)+c(i)*Pi(i).^2+abs(e(i)*sin(f(i)*(pmin-Pi(i))));
end
ok here the new code .....i'm feeding 'x' from an algorithm..its a 6x1 matrix. What i need in the end is Pi value which will have 6 values and i'll feed that value to the Ft formula in the end
Walter Roberson
2015 年 9 月 22 日
Pi is a vector but if the if comparing it to data(1,4) holds then you assign data(1,4) to replace ALL of the vector.
JL555
2015 年 9 月 22 日
ok last question...'x' out there like i said is a 6x1 matrix..in the 5th line my Pi should be a 6x1 matrix too right? but i'm getting a single value ..why?
JL555
2015 年 9 月 22 日
Yes all of x...But i did this instead Pi=[m n1]; still i,m getting one value..
JL555
2015 年 9 月 22 日
Oh and one thing ,i have the pseudo code of an algorithm ...any tutorials of how i can write that pseudo code into a matlab program..
Walter Roberson
2015 年 9 月 22 日
I explained several days ago why
Pi=[Pi Pi(i)];
is going to just end up copying the same element over and over again. You are ignoring everything I write about why your program is not working.
JL555
2015 年 9 月 22 日
ok sorry dude i've been working with this program for one month now i managed to eliminate all the errors but everything is wrong with the programming...anyway are u familiar with economic load dispatch??
Walter Roberson
2015 年 9 月 22 日
I am not familiar with economic load dispatch.
Note: I am not "dude". Or "man".
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Entering Commands についてさらに検索
タグ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
