フィルターのクリア

Inconsistency between sizes of second and third arguments

16 ビュー (過去 30 日間)
Pranav
Pranav 2023 年 1 月 13 日
回答済み: Piyush Patil 2023 年 3 月 3 日
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 件のコメント
Pranav
Pranav 2023 年 1 月 13 日
yeah, sure!
f = [(x^2) (y^2)]
r = [2*(x^2)] from (-1,2) to (2,8)
Dyuman Joshi
Dyuman Joshi 2023 年 1 月 13 日
You are trying to substitute 2 values but input is only single value.
Also, (-1,2) to (2,8) is input to I?

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

回答 (1 件)

Piyush Patil
Piyush Patil 2023 年 3 月 3 日
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]

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by