Inconsistency between sizes of second and third arguments
10 views (last 30 days)
Show older comments
Hi, I am getting an error while calculating work done with a given vector and parameter. How to rectify that?
F=subs(f,{x,y},r); % Inconsistency between sizes of second and third arguments
Fdr=sum(F.*dr); % [X2,Y2,symX,symY] = normalize(X,Y);
% My code is below:
clc
clear all
syms x y t
f=input('Enter the components of 2D vector function [u,v] ');
r=input('Enter x,y in parametric form');
I=input('Enter the limits of integration for t in the form [a,b]');
a=I(1);b=I(2);
dr=diff(r,t);
F=subs(f,{x,y},r);
Fdr=sum(F.*dr);
I=int(Fdr,t,a,b)
P(x,y)=f(1);Q(x,y)=f(2);
x1=linspace(-2*pi,2*pi,10); y1=x1;
[X,Y] = meshgrid(x1,y1);
U=P(X,Y); V=Q(X,Y);
quiver(X,Y,U,V,1.5)
hold on
t1=linspace(0,2*pi);
x=subs(r(1),t1);y=subs(r(2),t1);
plot(x,y,'r')
3 Comments
Dyuman Joshi
on 13 Jan 2023
You are trying to substitute 2 values but input is only single value.
Also, (-1,2) to (2,8) is input to I?
Answers (1)
Piyush Patil
on 3 Mar 2023
Hello Pranav,
You are getting an error because the input vector for the 2D vector function f is not of the same size as that of the input vector for r.
In your case, f has two components, so it is a 1x2 vector, while r has only one component, so it is a scalar.
In order to resolve this error, you can rewrite the parametric curve r in terms of t only.
For example, consider the vector function f = [x^2 y^2] over the parametric curve r = [2*(t^2) 4*(t^2)] where the limits of integration for t are [-4 4]
syms x y t
f = input('Enter the components of 2D vector function [u,v]: ');
r = input('Enter x,y in parametric form [x(t),y(t)]: ');
I = input('Enter the limits of integration for t in the form [a,b]: ');
a = I(1)
b = I(2)
dr = diff(r, t)
F = subs(f, {x,y}, r)
Where your inputs are -
f = [x^2 y^2]
r = [2*(t^2) 4*(t^2)]
I = [-4 4]
0 Comments
See Also
Categories
Find more on Mathematics and Optimization 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!