How to debug this type of error ??

2 visualizzazioni (ultimi 30 giorni)
d_p = 0.8;
d_b = 3.9;
c_b = 4.39;
l = 10.6;
n_t=6;
n_z=1;
nt = 400;
nz = 300;
i_c = 1.2;
x_1 = l-d_p-(d_b/2)-c_b;
x_2 = x_1-l;
xs=linspace(0,2*pi*r/n_t,nt/n_t);
y=linspace(x_2,x_1,nz/n_z);
[XS,Y]=meshgrid(xs,y);
I_1 = XS.^2 + Y.^2 - (i_c/2)^2;
I_2 =(XS-(pi*r/(n_t/2))).^2 + (Y).^2 - (i_c/2)^2;
F = I_1 <0 | I_2<0;
FF=repmat (F,n_z,n_t);
[nz,ntn]=size(FF);
x = linspace(0,2*pi*r,ntn);
[X,Y]=meshgrid(x,y);
mesh(x,y,FF)
ERROR:
Error using matlab.graphics.chart.primitive.Surface/set
While setting the 'ZData' property of 'Surface':
Value must be a scalar, vector or array of numeric type
Error in matlab.graphics.chart.internal.ctorHelper (line 6)
set(obj, pvpairs{:});
Error in matlab.graphics.chart.primitive.Surface
Error in mesh (line 133)
hh =
matlab.graphics.chart.primitive.Surface('XData',x,'YData',y,'ZData',z,...
Error in Untitled (line 23)
mesh(x,y,FF)

Risposta accettata

Walter Roberson
Walter Roberson il 20 Set 2017
Your FF is type logical not numeric. You can double(FF)
But I have to wonder... Your FF is already an array and then you repmat in both horizontal and vertical direction. The reason for that is not obvious.
  3 Commenti
Manas Ranjan Pattnayak
Manas Ranjan Pattnayak il 20 Set 2017
When I used FF= double(FF), i got the solution. Could you please explain the reason.
Thank You so much.
Walter Roberson
Walter Roberson il 20 Set 2017
F is logical, and when you repmat() logical you get something that is logical, so FF is logical. surf() does not accept logical.
F is logical because it is the result of the logical operations < and |

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by