Matlab interpolation of 4D scattered data












1















We have a 195x4 (double) matrix: A=[X Y Z temp], when ploted with scatter3(A(:,1), A(:,2), A(:,3),30, A(:,4), 'filled' ) gives something like this:
enter image description here



Now we want to generate a 'cube' colored with the interpolation of the temp=A(:,4) vector data.
So far we have tried interp3



% Base Grid
[Xm Ym Zm] = meshgrid(A(:,1), A(:,2), A(:,3));
% Grid Refinement
[Xq,Yq,Zq] = meshgrid(xmin:dx:xmax, ymin:dy:ymax, zmin:dz:zmax);
Aq = interp3(Xm,Ym,Zm,A(:,4),Xq,Yq,Zq);


Returns the following error:



Error using griddedInterpolant
The number of input coordinate arrays does not equal the number of dimensions
(NDIMS) of these arrays.

Error in interp3 (line 144)
F = griddedInterpolant(X, Y, Z, V, method,extrap);

Error in PDGEM_MT (line 112)
Aq = interp3(Xm,Ym,Zm,A(:,4),Xq,Yq,Zq);


So I think, may be a bad implementation and/or a wrong interpretation of the problem.
How to generate a 'cube'of that space colored with the volume interpolation of A(:,4)?



Thanks in advance.










share|improve this question





























    1















    We have a 195x4 (double) matrix: A=[X Y Z temp], when ploted with scatter3(A(:,1), A(:,2), A(:,3),30, A(:,4), 'filled' ) gives something like this:
    enter image description here



    Now we want to generate a 'cube' colored with the interpolation of the temp=A(:,4) vector data.
    So far we have tried interp3



    % Base Grid
    [Xm Ym Zm] = meshgrid(A(:,1), A(:,2), A(:,3));
    % Grid Refinement
    [Xq,Yq,Zq] = meshgrid(xmin:dx:xmax, ymin:dy:ymax, zmin:dz:zmax);
    Aq = interp3(Xm,Ym,Zm,A(:,4),Xq,Yq,Zq);


    Returns the following error:



    Error using griddedInterpolant
    The number of input coordinate arrays does not equal the number of dimensions
    (NDIMS) of these arrays.

    Error in interp3 (line 144)
    F = griddedInterpolant(X, Y, Z, V, method,extrap);

    Error in PDGEM_MT (line 112)
    Aq = interp3(Xm,Ym,Zm,A(:,4),Xq,Yq,Zq);


    So I think, may be a bad implementation and/or a wrong interpretation of the problem.
    How to generate a 'cube'of that space colored with the volume interpolation of A(:,4)?



    Thanks in advance.










    share|improve this question



























      1












      1








      1








      We have a 195x4 (double) matrix: A=[X Y Z temp], when ploted with scatter3(A(:,1), A(:,2), A(:,3),30, A(:,4), 'filled' ) gives something like this:
      enter image description here



      Now we want to generate a 'cube' colored with the interpolation of the temp=A(:,4) vector data.
      So far we have tried interp3



      % Base Grid
      [Xm Ym Zm] = meshgrid(A(:,1), A(:,2), A(:,3));
      % Grid Refinement
      [Xq,Yq,Zq] = meshgrid(xmin:dx:xmax, ymin:dy:ymax, zmin:dz:zmax);
      Aq = interp3(Xm,Ym,Zm,A(:,4),Xq,Yq,Zq);


      Returns the following error:



      Error using griddedInterpolant
      The number of input coordinate arrays does not equal the number of dimensions
      (NDIMS) of these arrays.

      Error in interp3 (line 144)
      F = griddedInterpolant(X, Y, Z, V, method,extrap);

      Error in PDGEM_MT (line 112)
      Aq = interp3(Xm,Ym,Zm,A(:,4),Xq,Yq,Zq);


      So I think, may be a bad implementation and/or a wrong interpretation of the problem.
      How to generate a 'cube'of that space colored with the volume interpolation of A(:,4)?



      Thanks in advance.










      share|improve this question
















      We have a 195x4 (double) matrix: A=[X Y Z temp], when ploted with scatter3(A(:,1), A(:,2), A(:,3),30, A(:,4), 'filled' ) gives something like this:
      enter image description here



      Now we want to generate a 'cube' colored with the interpolation of the temp=A(:,4) vector data.
      So far we have tried interp3



      % Base Grid
      [Xm Ym Zm] = meshgrid(A(:,1), A(:,2), A(:,3));
      % Grid Refinement
      [Xq,Yq,Zq] = meshgrid(xmin:dx:xmax, ymin:dy:ymax, zmin:dz:zmax);
      Aq = interp3(Xm,Ym,Zm,A(:,4),Xq,Yq,Zq);


      Returns the following error:



      Error using griddedInterpolant
      The number of input coordinate arrays does not equal the number of dimensions
      (NDIMS) of these arrays.

      Error in interp3 (line 144)
      F = griddedInterpolant(X, Y, Z, V, method,extrap);

      Error in PDGEM_MT (line 112)
      Aq = interp3(Xm,Ym,Zm,A(:,4),Xq,Yq,Zq);


      So I think, may be a bad implementation and/or a wrong interpretation of the problem.
      How to generate a 'cube'of that space colored with the volume interpolation of A(:,4)?



      Thanks in advance.







      matlab 3d grid interpolation 4d






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 3:33







      cavereaper

















      asked Nov 21 '18 at 2:10









      cavereapercavereaper

      225




      225
























          1 Answer
          1






          active

          oldest

          votes


















          2














          You have an scattered dataset.



          interp3 does only work if your data points are in meshgrid format read this. The short description of this function is Interpolation for 3-D gridded data in meshgrid format



          Instead you can use griddata which works for scattered data read this. The short description is Interpolate 2-D or 3-D scattered data.



          Example:



          X = rand(100,1);
          Y = rand(100,1);
          Z = rand(100,1);
          C = rand(100,1);

          figure
          scatter3(X, Y, Z,30, C, 'filled' )

          [Xm, Ym, Zm] = meshgrid(min(X):.01:max(X), min(Y):.01:max(Y), min(Z):.01:max(Z));

          Cm = griddata(X,Y,Z,C,Xm,Ym,Zm);

          figure
          scatter3(Xm(:), Ym(:), Zm(:), 30, Cm(:), 'filled' )


          Data points:
          data



          Interpolated:
          gridded






          share|improve this answer
























          • worked like a charm. Vielen Dank, Sie sind sehr nett.

            – cavereaper
            Nov 21 '18 at 18:13











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404381%2fmatlab-interpolation-of-4d-scattered-data%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          You have an scattered dataset.



          interp3 does only work if your data points are in meshgrid format read this. The short description of this function is Interpolation for 3-D gridded data in meshgrid format



          Instead you can use griddata which works for scattered data read this. The short description is Interpolate 2-D or 3-D scattered data.



          Example:



          X = rand(100,1);
          Y = rand(100,1);
          Z = rand(100,1);
          C = rand(100,1);

          figure
          scatter3(X, Y, Z,30, C, 'filled' )

          [Xm, Ym, Zm] = meshgrid(min(X):.01:max(X), min(Y):.01:max(Y), min(Z):.01:max(Z));

          Cm = griddata(X,Y,Z,C,Xm,Ym,Zm);

          figure
          scatter3(Xm(:), Ym(:), Zm(:), 30, Cm(:), 'filled' )


          Data points:
          data



          Interpolated:
          gridded






          share|improve this answer
























          • worked like a charm. Vielen Dank, Sie sind sehr nett.

            – cavereaper
            Nov 21 '18 at 18:13
















          2














          You have an scattered dataset.



          interp3 does only work if your data points are in meshgrid format read this. The short description of this function is Interpolation for 3-D gridded data in meshgrid format



          Instead you can use griddata which works for scattered data read this. The short description is Interpolate 2-D or 3-D scattered data.



          Example:



          X = rand(100,1);
          Y = rand(100,1);
          Z = rand(100,1);
          C = rand(100,1);

          figure
          scatter3(X, Y, Z,30, C, 'filled' )

          [Xm, Ym, Zm] = meshgrid(min(X):.01:max(X), min(Y):.01:max(Y), min(Z):.01:max(Z));

          Cm = griddata(X,Y,Z,C,Xm,Ym,Zm);

          figure
          scatter3(Xm(:), Ym(:), Zm(:), 30, Cm(:), 'filled' )


          Data points:
          data



          Interpolated:
          gridded






          share|improve this answer
























          • worked like a charm. Vielen Dank, Sie sind sehr nett.

            – cavereaper
            Nov 21 '18 at 18:13














          2












          2








          2







          You have an scattered dataset.



          interp3 does only work if your data points are in meshgrid format read this. The short description of this function is Interpolation for 3-D gridded data in meshgrid format



          Instead you can use griddata which works for scattered data read this. The short description is Interpolate 2-D or 3-D scattered data.



          Example:



          X = rand(100,1);
          Y = rand(100,1);
          Z = rand(100,1);
          C = rand(100,1);

          figure
          scatter3(X, Y, Z,30, C, 'filled' )

          [Xm, Ym, Zm] = meshgrid(min(X):.01:max(X), min(Y):.01:max(Y), min(Z):.01:max(Z));

          Cm = griddata(X,Y,Z,C,Xm,Ym,Zm);

          figure
          scatter3(Xm(:), Ym(:), Zm(:), 30, Cm(:), 'filled' )


          Data points:
          data



          Interpolated:
          gridded






          share|improve this answer













          You have an scattered dataset.



          interp3 does only work if your data points are in meshgrid format read this. The short description of this function is Interpolation for 3-D gridded data in meshgrid format



          Instead you can use griddata which works for scattered data read this. The short description is Interpolate 2-D or 3-D scattered data.



          Example:



          X = rand(100,1);
          Y = rand(100,1);
          Z = rand(100,1);
          C = rand(100,1);

          figure
          scatter3(X, Y, Z,30, C, 'filled' )

          [Xm, Ym, Zm] = meshgrid(min(X):.01:max(X), min(Y):.01:max(Y), min(Z):.01:max(Z));

          Cm = griddata(X,Y,Z,C,Xm,Ym,Zm);

          figure
          scatter3(Xm(:), Ym(:), Zm(:), 30, Cm(:), 'filled' )


          Data points:
          data



          Interpolated:
          gridded







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 '18 at 8:43









          user7431005user7431005

          980416




          980416













          • worked like a charm. Vielen Dank, Sie sind sehr nett.

            – cavereaper
            Nov 21 '18 at 18:13



















          • worked like a charm. Vielen Dank, Sie sind sehr nett.

            – cavereaper
            Nov 21 '18 at 18:13

















          worked like a charm. Vielen Dank, Sie sind sehr nett.

          – cavereaper
          Nov 21 '18 at 18:13





          worked like a charm. Vielen Dank, Sie sind sehr nett.

          – cavereaper
          Nov 21 '18 at 18:13


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404381%2fmatlab-interpolation-of-4d-scattered-data%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?