How to fix "Error using > Matrix dimensions must agree" ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Mohammad Sulaiman Stanekzai
el 29 de Ag. de 2019
Comentada: Mohammad Sulaiman Stanekzai
el 29 de Ag. de 2019
How to fix the problem?
My code is like this
if load(sun,1) > pv (sun,1); POL = SUM;
yy = load(sun,1) - pv (sun,1); % (Eksik olan Enerjinin Degeri)
yy1(sun,1) = double (yy);
yy2 = sum (yy1); % importanttttttttttttttttttttttttt(Eloss)
QQS = find(yy1<640.0184);
QQa = yy1(QQS);
QQL = find (yy1>640.0184);
QQb = yy1(QQL);
TOtal = sum (QQb);
v = pemfc(find( pemfc > QQa(:,1) , 1 ) ); % very important (Eksik olan enerjinin PEMFC'daki belirli aralikta çalismasi)
x = v ; % (Eksik olan enerjinin - olarak gösterilmesi)
j(sun,1) = double (x); % (toplam Eksik olan enerjinin PEMFC'daki belirli aralikta çalismasi)
h2miktar = (j*(213.3395/640.0184)); %(depo(q,1))
m = double (h2miktar); % (Hidrojen miktari) (m(q,1))
h2t = sum(m); % Toplam Hidrojen Miktari
h2t2 = h2t - (h2+ POL);
RemainingPower = (h2t2*640.0184)/213.3395;
TOTALremain = RemainingPower + TOtal;
Lossofload = TOTALremain/Load;
Q1 =find(m>0);
answer1 = m(Q1);
WWW = sum(answer1);
end
The error shows me the following line:
Error using > Matrix dimensions must agree.
Error in LAST (line 55)
v = pemfc(find( pemfc > QQa(:,1) , 1 ) );
Something is wrong with "QQa" variable. I want to find first maximum value from pemfc file for QQa parameter.
by the way pemfc = [0
14.6160000000000
27.2182400000000
39.5606400000000
51.4483200000000
63.2548000000000
100.1262400000000
150.7378400000000
200.8297600000000
225.743040000000]
and QQa = [60
60
60
60
3.39799267351160
205.646953910377
220.663912150683
206.033491851057 ]
For Firs value of QQa it select first maxumum values like (63.2548000000000)
For second value of QQa it select first maxumum values like (63.2548000000000)
For sixth value of QQa it select first maxumum values like (225.743040000000)
and so on
Thanks in advance.
4 comentarios
Joel Handy
el 29 de Ag. de 2019
pemfc > QQa(:,1)
This code does an elementwise comparison of pemfc and QQa(:,1). Thats why you are getting a matrix dimension error. Generally its worth avoiding for loops (hence the comment and not an official answer), but for the purposes of explaining the problem, what you are really want to do is. . .
for idx = 1:numel(QQa(:,1))
v(idx) = pemfc(find( pemfc > QQa(idx,1) , 1 ) );
end
Respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!