matrix is singular to working precision , Contour not rendered for non-finite ZData
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
Hello,
I have read through all the trouble shooting advice on this website for the above error. I have attached my code, and I am not sure what I am doing that is causing this error.
Could somebody guide me what I am doing wornk? 
Thanks.
function [] = Plot3D(cellArray,charArray)
x = linspace(-15,15,100);
y = linspace(-15,15,100);
[xx,yy] = meshgrid(x,y);
z = (sin(sqrt(xx .^2 + yy .^2)))/(sqrt(xx .^2 +yy .^2));
switch charArray
    case 'surfc'
        surfc(xx,yy,z);
        xlabel(cellArray{2});
        ylabel(cellArray{4});
        zlabel(cellArray{6});              
    case 'surf'       
        surf(xx,yy,z);
        grid on;
        title("This is the surf:");        
    case 'contour'
        grid on;
        contour(xx,yy,z,'ShowText','on');
        axis([-15 15 -15 15 -15 15]);
    otherwise
        subplot(2,2,1);        
        surfc(xx,yy,z);      
        subplot(2,2,2);        
        surf(xx,yy,z);
        subplot(2,2,[3,4]);
        contour(xx,yy,z);
end
3 comentarios
  Abderrahim. B
      
 el 21 de Jul. de 2022
				Hi!
Please, share the error. And if possible, share cellArray and charArray. 
Thanks
Respuestas (1)
  Shivam
      
 el 5 de Oct. de 2023
        As per my understanding, you are trying to make different figures using surfc, surf, contour, and plot3, where the provided code's execution is leading to warnings. 
You can overcome the warnings by utilizing element-wise division instead of regular division when calculating the variable 'z.' The updated code line would look as follows:
z = (sin(sqrt(xx .^2 + yy .^2)))./(sqrt(xx .^2 +yy .^2));
I hope it helps.
0 comentarios
Ver también
Categorías
				Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


