error "Inner matrix dimensiion must Agree"
Show older comments
Please I'm trying to plot graphs and varying parameter Gr and t which is temperature. But i keep getting an error "Inner matrix dimensiion must Agree"
>> Gr = [5:5:25];
>> t = [0.2:0.2:1];
>> H = 1;
>> n = 1;
>> N = 5;
>> Pr = 0.72;
>> S = 0.2;
% This is my code
>> U = -Gr*(t.^2/2 + Pr*(N-n)*(t.^4/24 - t.^2/4) + (Pr*(N-n))^2*(t.^6/720 - t.^4/48 + 5*t.^2)...
+ (Pr*(N-n))^3*(t.^8/40320 - t.^6/1440 + 5*t.^4/576 - 61*t.^2/1440) + (Pr*(N-n))^4*(t.^10/36288000 - t.^8/80640 + 5*t.^6/17280 -61*t.^4/17280 + 1385*t.^2/806400)...
- 1/2 + Pr*(N-n)*5/24 - (Pr*(N-n))^2*61/720 + (Pr*(N-n))^3*277/8064 - (Pr*(N-n)^4*(0.014))...
-(S + H - n)*Gr*(t.^4/24 * Pr*(N-n)*(t.^6/720 - t.^4/48) + (Pr*(N - n))^2*(t.^8/40320 - t.^6/1440 + 5*t.^4/576)...
+ (Pr*(N-n))^3*(t.^10/32688000 - t.^8/80640 + 5*t.^6/17280 + 61*t.^4/17280) + (Pr*(N-n))^4*(t.^12/479001600 - t.^10/7257600 + 5*t.^8/967680 - 61*t.^6/518400 + 1385*t.^4/967680)...
- t.^2/4 + Pr*(N-n)*5*t.^2/48 - (Pr*(N-n))^2*61*t.^2/1440 + (Pr*(N-n))^3*277*t.^2/16128 - (Pr*(N-n))^4*(7*t.^2/1000))...
-(1/24 + Pr*(N-n)*(1/720 -1/48) + (Pr*(N-n))^2*(1/40320 - 1/1440 + 5/576) + (Pr*(N-n))^3*(1/36288000 - 1/80640 + 5/17280 - 61/17280) + (Pr*(N-n))^4*(1/479001600 - 1/7257600 + 5/967680 - 61/518400 + 1385/967680)...)
-1/4 + Pr*(N-n)*5/48 - (Pr*(N-n))^2*61/1440 + (Pr*(N-n))^3*277/16128-(Pr*(N-n))^4*(7/100)))
Error using *
Inner matrix dimensions must agree.
>>
>>
Accepted Answer
More Answers (1)
GR = [5:5:25];
T = [0.2:0.2:1];
H = 1;
n = 1;
N = 5;
Pr = 0.72;
S = 0.2;
for i = 1:numel(GR)
Gr = GR(i);
for j = 1: numel(T)
t = T(j);
U(i,j) = -Gr*(t.^2/2 + Pr*(N-n)*(t.^4/24 - t.^2/4) + (Pr*(N-n))^2*(t.^6/720 - t.^4/48 + 5*t.^2)...
+ (Pr*(N-n))^3*(t.^8/40320 - t.^6/1440 + 5*t.^4/576 - 61*t.^2/1440) + (Pr*(N-n))^4*(t.^10/36288000 - t.^8/80640 + 5*t.^6/17280 -61*t.^4/17280 + 1385*t.^2/806400)...
- 1/2 + Pr*(N-n)*5/24 - (Pr*(N-n))^2*61/720 + (Pr*(N-n))^3*277/8064 - (Pr*(N-n)^4*(0.014))...
-(S + H - n)*Gr*(t.^4/24 * Pr*(N-n)*(t.^6/720 - t.^4/48) + (Pr*(N - n))^2*(t.^8/40320 - t.^6/1440 + 5*t.^4/576)...
+ (Pr*(N-n))^3*(t.^10/32688000 - t.^8/80640 + 5*t.^6/17280 + 61*t.^4/17280) + (Pr*(N-n))^4*(t.^12/479001600 - t.^10/7257600 + 5*t.^8/967680 - 61*t.^6/518400 + 1385*t.^4/967680)...
- t.^2/4 + Pr*(N-n)*5*t.^2/48 - (Pr*(N-n))^2*61*t.^2/1440 + (Pr*(N-n))^3*277*t.^2/16128 - (Pr*(N-n))^4*(7*t.^2/1000))...
-(1/24 + Pr*(N-n)*(1/720 -1/48) + (Pr*(N-n))^2*(1/40320 - 1/1440 + 5/576) + (Pr*(N-n))^3*(1/36288000 - 1/80640 + 5/17280 - 61/17280) + (Pr*(N-n))^4*(1/479001600 - 1/7257600 + 5/967680 - 61/518400 + 1385/967680)...)
-1/4 + Pr*(N-n)*5/48 - (Pr*(N-n))^2*61/1440 + (Pr*(N-n))^3*277/16128-(Pr*(N-n))^4*(7/100)));
end
end
contourf(GR,T,U)
colorbar
3 Comments
- (Pr*(N-n))^4*(0.014)
instead of
- (Pr*(N-n)^4*(0.014))
The printed formula is full of imbalanced parentheses, so that's just the way I read it.
EDIT: also, the way U is addressed is transposed with respect to how it's plotted. It's easy to miss since the vectors have the same length.
Maduka
on 18 Dec 2022
Maduka
on 18 Dec 2022
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






