ex[Y,Z]=meshgrid(5:5:35,10:5:90);
cl=reshape(v,17,7);
cd=reshape(w,17,7);
bal=reshape(x,17,7);
Map1=interp2(cl,cd,bal,a,b);
surf(Map1,Y,Z)
v, w, and x all represent xlsreads. a and b are single numbers prompted by the user.
I am trying to graph these points on a 3d surface plot, but I always get the error using interp2: EXTRAPVAL must be a scalar. When I move certain variables around, the error then becomes: not monotonically increasing.
Please help, I can not figure this out.

6 Kommentare

Stephen23
Stephen23 am 10 Dez. 2018
I don't get any error:
>> [Y,Z] = meshgrid(5:5:35,10:5:90);
>> cl = reshape(1:17*7,17,7);
>> cd = reshape(sqrt(1:17*7),17,7);
>> bal = reshape(pow2(1:17*7),17,7);
>> Map1=interp2(cl,cd,bal,1,2)
Map1 = 16
>> Map1=interp2(cl,cd,bal,1:5,2:6)
Map1 =
16.00000 3948062.11765 1010638366.11765 NA NA
madhan ravi
madhan ravi am 10 Dez. 2018
When surf is used the first argument cannot be a scalar.
prompt='What is the front ride height?: ';
a=input(prompt,'s');
prompt='What is the rear ride height?: ';
b=input(prompt,'s');
This is the beginning of my code for my a and b variables. When I try using numbers in my Map1 definition (such as 1,2 or 1:5,2:6 as you used), I then get the error: Input grid is not a valid MESHGRID. When I change them back to a,b I again recieve the EXTRAPVAL must be a scalar error.
madhan ravi
madhan ravi am 10 Dez. 2018
did you see my answer ? @Cory
Cory Runnells
Cory Runnells am 10 Dez. 2018
@madhan ravi Surf is not where I am currently having the issue. This error occurs during the interp2 line of code and the program will not advance.
The problem with the code you posted two comments above is the 's' in your input statements. When you use 's' in input it returns what the user entered as text, not as numbers. Because of that, I believe MATLAB interprets your interp2 call as the "Vq = interp2(V, Xq, Yq, METHOD, EXTRAPVAL)" signature instead of "Vq = interp2(X, Y, V, Xq, Yq)".
Instead, have input return what the user entered as numbers.
prompt='What is the front ride height?: ';
a=input(prompt);
prompt='What is the rear ride height?: ';
b=input(prompt);

Melden Sie sich an, um zu kommentieren.

Antworten (3)

madhan ravi
madhan ravi am 10 Dez. 2018
Bearbeitet: madhan ravi am 10 Dez. 2018

0 Stimmen

EDITED
[Y,Z]=meshgrid(5:5:35,10:5:90);
cl=reshape(v,17,7);
cd=reshape(w,17,7);
bal=reshape(x,17,7);
prompt='What is the front ride height?: ';
a=input(prompt);
prompt='What is the rear ride height?: ';
b=input(prompt);
ab=[a b];
[A,B]=meshgrid(min(ab):0.25:max(ab)); %reduce the step size if finer grid is wanted
Map1=interp2(cl,cd,bal,A,B);
surf(Map1,Y,Z)

4 Kommentare

Cory Runnells
Cory Runnells am 10 Dez. 2018
Thanks so much @madhan ravi!
madhan ravi
madhan ravi am 10 Dez. 2018
Anytime :)
Cory Runnells
Cory Runnells am 10 Dez. 2018
Ok, I assumed your code would work, but I am still recieving the same error: Input grid is not a valid MESHGRID. Any more ideas?
madhan ravi
madhan ravi am 10 Dez. 2018
upload your datas as .mat file to test

Melden Sie sich an, um zu kommentieren.

Cory Runnells
Cory Runnells am 10 Dez. 2018

0 Stimmen

There's bunches of garbage code at the bottom since I'm testing things. But see if you can spot the error

5 Kommentare

madhan ravi
madhan ravi am 10 Dez. 2018
attach your excel file and remove the inputs and just fill it up with values , please make it easier for us debug
Cory Runnells
Cory Runnells am 10 Dez. 2018
Hopefully this makes it easier
madhan ravi
madhan ravi am 10 Dez. 2018
provide the input values .... a,b,c,,,etc..
Cory Runnells
Cory Runnells am 10 Dez. 2018
a=6 b=7 c=8 d=9; really any input values are what I want to work.
madhan ravi
madhan ravi am 10 Dez. 2018
ok cory , you can unaccept my answer , Star Strider is really an expert in this , he can easily debug it.

Melden Sie sich an, um zu kommentieren.

Stephen23
Stephen23 am 10 Dez. 2018
Bearbeitet: Stephen23 am 10 Dez. 2018

0 Stimmen

Add str2double:
a = str2double(input(prompt,'s'));
...
b = str2double(input(prompt,'s'));
This is more robust than calling input without the 's' option.

Kategorien

Mehr zu Programming finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 10 Dez. 2018

Bearbeitet:

am 10 Dez. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by