필터 지우기
필터 지우기

FSOLVE requires all values returned by functions to be of data type double. showing while solving an algebraic equation in matlab ??

조회 수: 1 (최근 30일)
I want to solve the eqs for u_s and find out the value of u_s but i am getting error while solving the equation using fsolve. Can you provide some solution for this problem ?? Thank you
type untitled03.m
clc clear close all a = deg2rad(45); m = 0.683; We = 277; Re = 75; b = (-0.13*m.^3+0.263*m.^2 +0.039*m +0.330)/tan(a); s_b = 0.0042; p = pi/2; R = 1.7440; t = deg2rad(0); syms q x = b*cos(t)*sin(a)^2; x01 = 4*((1-cos(t)^2*cos(a)^2)); x02 = (b*sin(t)*sin(a))^2; q_j = -((x -(x01-x02)^0.5)/(x01/4)); d = (b^2*sin(a)^2 + q^2*(1-cos(t)^2*cos(a)^2) + 2*b*q*cos(t)*sin(a)^2)^0.5; u_j = 2*(m-1)*(4*d^2-1) + m; F = int(q*u_j, q, 0, q_j); G = int(q*u_j^3,q,0,q_j); eqs = @(u_s)((4*sin(a).^3*F.^4*(R-q_j)*(R.^5-q_j.^5))/(15*q_j.^7*R.^5*Re))+... ((((R.^3-q_j.^3)*F.^3*sin(a).^3)/(9*q_j.^3*R.^3))-((R-q_j)*F*((4/q_j)+sin(a))))*u_s+... (R-q_j)*F*sin(a)*u_s.^3+... (R.^2 +2*R*sqrt(pi*s_b))+(16*F.^3*sin(a)*(R-q_j).^2)/(3*q_j.^3*R*Re)*u_s^2; sol = fsolve(eqs,0.5);

채택된 답변

Walter Roberson
Walter Roberson 2023년 12월 8일
F and G are int() calls. Even if they evaluate to closed forms that were rational numbers, they have symbolic results. When you create an anonymous function that includes F and G, any numeric coefficients will be converted to symbolic at the point F or G is encountered, so the anonymous function will return something of data type sym even in the best possible case. But fsolve requires single or double. fsolve refuses to even try to convert sym to double.
Instead of constructing that anonymous function you should use matlabFunction()
  댓글 수: 7

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by