Vpasolve higher polynomials does not give a real solution

equation_clean = poly2sym(p,t) %the equation of the polynomial interpolation
yvalues = polyval(p,a,[],mu); %yvalues of the linear interpolation
hold off
slope_graph = polyfit(a,yvalues,1);
T = yvalues(1:14);
stand_dev = std(T);
while stand_dev < .03
counter = counter + 1;
T(counter) = yvalues(counter);
stand_dev = std(T);
end
max_ind = find(a,1,'last');
ts_ind = find(yvalues == T(counter),1,'last');
ts = a(ts_ind);
Temperature2 = yvalues(max_ind:-1:ts_ind);
T_2 = Temperature2(1:14);
stand_dev = 0;
counter = 14;
while stand_dev < .03
counter = counter + 1;
T_2(counter) = Temperature2(counter);
stand_dev = std(T_2);
end
yH_ind = find( Temperature2 == T_2(counter),1,'last');
if slope_graph(1) > 0
yL = mean(T)
yH = Temperature2(yH_ind)
else
yL = Temperature2(yH_ind)
yH = mean(T)
end
y_tau = .632 * (yH - yL)
ts
x_tau_t = vpasolve(equation_clean == y_tau,t,[0 Inf])
tau = x_tau_t(end) - ts;
Hello everyone, I need your help.
I am super beginner at Matlab, but have a challenging task in front of me. I want to find out tau value, I calculatd ts and y_tau. Now I just need to plug in value for y_tau and determine x_tau from it. However matlab tells me that the number does not exist, so there is no solution. but when I draw the graph it is obvious that there is a positive interger solution which is close to 1.7 seconds. Any help would be much appreciated. I have used polynomial interpolation or polyval to determine the polynomial equation.

回答(1 个)

Q: "We need to know what inputs to test with ?"
A: "The inputs are given by the user"
Given that, then we can conclude that you are wrong about there being an error with the program. See attached implementation code.

3 个评论

[p,~,mu] = polyfit(x,y,20); %use polyfit to get the coefficiants of the polynomial
figure(1) %figure 1
[a,b] = selection_data(x,y);
plot(a,b,'ko'); %plot the originaldata
grid on
xlabel("x")
ylabel("y")
hold on
t = sym('t');
equation_clean = poly2sym(p,t) %the equation of th epolynomial interpolation
yvalues = polyval(p,a,[],mu);
This is the part that I get inputs and plot it and make a polynomial interpolation using polyval/
Sorry for not displaying my code clearly
We do not have your x or your y, and we do not have your function selection_data

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by