Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Plot unit circle in chebychev metric in MATLAB

  1. Aug 1, 2012 #1
    Ok, so I'm trying to plot the unit circle using the chebyvhev metric, which should give me a square. I am trying this in MATLAB, using the 'pdist' and 'cmdscale' functions. My uber-complex code is the following:

    clc;clf;clear all;
    boundaryPlot=1.5;

    % Euclidean unit circle
    for i=1:360
    theta(i)=deg2rad(i);
    end
    zc=[cos(theta)' sin(theta)'];

    % Transform to Chebychev metric
    x=zc(:,:);
    D=pdist(x,'chebychev');
    D1=squareform(D);
    y=cmdscale(D1);


    % Plots
    hold on
    plot(y(:,1),y(:,2));
    axis square;axis([-boundaryPlot boundaryPlot -boundaryPlot boundaryPlot])
    plot([-boundaryPlot boundaryPlot],[0 0],'k')
    plot([0 0],[-boundaryPlot boundaryPlot],'k')

    where the part in bold is the really important part of the code. I have two problems with this. First, the 'y' variable which is supposed to hold the coordinates under the new metric has a size of 360x180. One of these dimensions should have been 2, which is the dimension of the L-p space (p=2).

    My second problem is that I get the plot you can see in the attachment, which corresponds to the Manhatan metric, and has rounded edges for some reason.

    Has anyone done this calculation before? Is there some other syntax/function I should be using??
     

    Attached Files:

  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Plot unit circle in chebychev metric in MATLAB
  1. Metric/metric tensor? (Replies: 1)

Loading...