Prashant Kumar
PhD Expert
Answered Aug 25, 2026
interp1 is incompatible with symbolic parameters. You CANNOT use interp1 with solve. Period. So wherever you found that snippet of code, they were wrong.
You can use a tool like fzero with interp1. fzero and interp1 are compatible.
Next, looking at your problem, this is actually a TWO variable problem, with two equations. That is, we have known constants, a,b,c,h. And there are two unknowns. Sadly, you seem to be using p in two places at once, both as an array of known elements, and as a variable. And that is confusing as hell.
So I'll make the assumption that you have two variales, I'll call then T and p_T. That is p_T is given as:
p_T = interp1(p(:,1),p(:,2),T)
So, if I knew the value of T, then I could compute P_T. And then we have a second equation:
h = a * T + p_T * (b + c * T)
Now we can just substitute P_T in there. This reduces the problem to ONE equation, in one unknown, where you can use fzero. I've re-arranged it to be something you can see as a problem for fzero.
a * T + interp1(p(:,1),p(:,2),T) * (b + c * T) - h = 0
Now, given the variables a,b,c,h and the array p are defined as MATLAB variables in your workspace, set it up as:
fun = @(T) a * T + interp1(p(:,1),p(:,2),T) * (b + c * T) - h;
Tfinal = fzero(fun,[p(1,1),p(end,1)]);
That call will set a bracket on T, such that T must always lie between P(1,1) and P(69,1). That must make sense, since interp1 cannot intelligently evaluate its function beyond those limits anyway.
Again, a,b,c,h and p must all be previously defined in your workspace for that to work.
vq = interp1(x,v,xq) returns interpolated values of a 1-D function at specific query points using linear interpolation. Vector x contains the sample points, and v contains the corresponding values, v(x). Vector xq contains the coordinates of the query points.
If you have multiple sets of data that are sampled at the same point coordinates, then you can pass v as an array. Each column of array v contains a different set of 1-D sample values.
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee