Matlab Error: Matrices must agree

Hello,
I am programming the following function:
V = 500;
c2 = 10;
Pv = 1/V;
% IvLin = a1*v; %what is v?
% IvQuad = a2*v^2;
% PDvLin = c2/v; %linear?
% PDvQuad = c2/(v^2); %quad?
%%%%%%Solve for a1 or a2 %%%%%%%
% size(c2)
% size(V)
% size(Pv)
funequ2 = @(v) v*(c2/v)*(1/V);
size(funequ2)
Equation2 = integral(funequ2,0,V);
funequ1 = @(v) (a1*v).*Pv;
Equation1 = integral(funequ1,0,V);%what is the upperbound
syms a1
solve(Equation1 == Equation2
For some reason it is not solving anything because I keep getting the error that the matrices must agree. When I checked the size of my components, they are all the same (1,1). I don't understand what the problem is. Could someone kindly help and provide some insight? This seems like it should have very simple.
Kam

4 件のコメント

Jason Ross
Jason Ross 2013 年 3 月 26 日
edited and used the code tag for clarity
PT
PT 2013 年 3 月 26 日
Would it help if you convert all multiplicative operations to element-wise (Use .* and ./ instead of * and /, respectively)?
Walter Roberson
Walter Roberson 2013 年 3 月 26 日
You have not shown us a1
Kam Selley
Kam Selley 2013 年 3 月 28 日
Hi Walter,
a1 is my unknown and what I am solving for.

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

回答 (1 件)

Youssef  Khmou
Youssef Khmou 2013 年 3 月 26 日

0 投票

hi,
a1 is unknown, but check this solution , although the code technically correct , the solution is empty :
%dbstop if error
V = 500;
c2 = 10;
a1=10;
Pv = 1/V;
funequ1 = @(v) v.*(c2./v)*(1/V);
f1=funequ1(1:0.1:10);
F1 = integral(f1,0.1);
funequ2 = @(v) (a1*v).*Pv;
f2=funequ2(1:0.1:10);
F2=integral(f2,0.1);
solve(F1 == F2)

3 件のコメント

Kam Selley
Kam Selley 2013 年 3 月 26 日
Hello,
I am trying to solve for a1 so that is why a1 is not defined.
Youssef  Khmou
Youssef Khmou 2013 年 3 月 26 日
In this case then :
SOL=solve('v*(c2/v)*(1/V)-(a1*v)*Pv=0','a1');
>> SOL
SOL =
c2/V/v/Pv
a1=c2/V/v/Pv
Kam Selley
Kam Selley 2013 年 3 月 28 日
I am not sure I can follow what you actually did. Did you just solve the integrals yourself instead of letting matlab do it. The error for your above answer says there's not enough input arguments.

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

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

質問済み:

2013 年 3 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by