이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Index problem help?
조회 수: 11 (최근 30일)
이전 댓글 표시
채택된 답변
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일
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!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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 (한국어)
