필터 지우기
필터 지우기

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 CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by