Info

This question is closed. Reopen it to edit or answer.

Problem generating genric 3-d shapes

1 view (last 30 days)
IISc
IISc on 19 Aug 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
Hello, I am working on an obstacle avoidance problem for an unmanned system. I need to generate a 3-d plot wherein i wish to place objects of various shapes and sizes.
Based on attached file information i prepared a code as follows
function [x,y,z] = obstac
clc
clear all
k1 = 1;
k2 = 1;
k3 = 1;
k4 = 1;
rho = 6;
x = -1:0.1:1;
y = -1:0.1:1;
lenx = length(x);
leny = length(y);
z = zeros(leny,lenx);
for i = 1:lenx
for j = 1:leny
z(j,i) = fzero(@(z)normal(rho,x(i),y(j),z,k1,k2,k3,k4),z(j,i));
end
end
surface(x,y,-z)
function f = normal(rho,x,y,z,k1,k2,k3,k4)
xc = 0;
yc = 0;
zc = 0;
bs = 100;
f = norm([(x-xc)/(k1+bs); (y-yc)/(k2+bs); (z-zc)/(k3+bs)],rho) - k4^rho ;
But i am not able to get the results as shown above. I wish to know following what is wrong with my code. I shall be very grateful if someone can help me create various 3-d shapes using a generic routine as above. regards, Tarun Uppal

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!