Matlab路径中不接受Class文件夹

时间:2019-01-10 15:55:45

标签: matlab plot

我正在尝试使用What's the difference between faking, mocking, and stubbing?进行一些高级数据绘制,但是我似乎无法用它完成一个简单的“ hello world”绘制。

也就是说,当我在其examples.m文件中运行任何代码单元时,都会遇到此与路径相关的错误:

Undefined function or variable 'parse_aes'.
Error in gramm (line 177)
            obj.aes=parse_aes(varargin{:});

尽管已将Gramm文件夹(c:\ Program Files \ MATLAB \ R2016a \ toolbox \ gramm \;是@gramm文件夹的父文件夹)递归添加到Matlab的路径,即及其所有子目录。根据自述文件,这是唯一必需的安装步骤。

我猜问题出在类文件夹/定义中,但是不幸的是我对面向对象编程一无所知。

我正在运行Matlab 2016a,并根据工具箱要求安装了统计信息和曲线拟合工具箱。

有人可以建议我尝试其他方法吗? (代码作者本人似乎没有直接/即时的支持)

2 个答案:

答案 0 :(得分:3)

您不想将所有目录递归添加到路径,只需添加包含var filepath = companyDetails.SPOD_DOCUMENT; document.querySelector('#link').setAttribute('href', '@Url.Action("ReturnPdf", "Main", new { path = filepath })'); 类文件夹的顶层目录即可。

如果添加子目录,则比类定义文件要多@gramm/gramm.m,并且在调用@gramm和{{1 }}文件夹(和gramm)不会与该类实例正确关联。

如果您重新阅读安装说明,则不会提及递归添加目录,而只是添加顶层目录:

  

...(使用GUI或@gramm)将包含@gramm/private类文件夹的文件夹添加到您的Matlab路径

答案 1 :(得分:0)

即使根据Suever的回复修复了路径(需要以非递归方式添加),我仍然遇到相同的错误。

提示是Matlab重新启动后显示的消息:

    private void SetupImageGrid()
    {
        dgvImages.Rows.Clear();
        dgvImages.Columns.Clear();
        dgvImages.SuspendLayout();

        for (int i = 1; i <= ImageColumns; i++)
        {
            DataGridViewTextBoxColumn captionCol = new DataGridViewTextBoxColumn();
            captionCol.Resizable = DataGridViewTriState.NotSet;
            captionCol.Width = 75;
            captionCol.Visible = true;
            captionCol.Name = string.Format("colCaption{0}", i);
            captionCol.DefaultCellStyle.Font = new Font(dgvImages.DefaultCellStyle.Font, FontStyle.Bold);
            dgvImages.Columns.Add(captionCol);

            DataGridViewTextBoxColumn filenameCol = new DataGridViewTextBoxColumn();
            filenameCol.Visible = false;
            filenameCol.Name = string.Format("colFilename{0}", i);
            dgvImages.Columns.Add(filenameCol);

            DataGridViewImageColumn imageCol = new DataGridViewImageColumn();
            imageCol.Width = ImageColumnWidth*30;
            imageCol.ImageLayout = DataGridViewImageCellLayout.Stretch;
            imageCol.Name = string.Format("colImage{0}", i);
            dgvImages.Columns.Add(imageCol);
        }
    }

    private void FillImageGrid(int ImageColumns)
    {
        SetupImageGrid();

        string imageAddr = "{Image File or FLD file containing a list of images}";
        string imageExt = "";
        bool noImagesInFLD = false;
        bool AtLeastOneImageFound = false;


        if (imageAddr != "")
        {
            if (File.Exists(imageAddr))
            {
                imageExt = Path.GetExtension(imageAddr);
                switch (imageExt)
                {
                    case ".FLD":
                        clsFolder FLD = new clsFolder();
                        FLD.FolderName = imageAddr;
                        FLD.OpenFolder();

                        if (FLD.FolderItems.Count == 0)
                        {
                            noImagesInFLD = true;
                        }
                        break;
                    default:
                        break;
                }

                Image[] img = new Image[ImageColumns];
                string[] caption = new string[ImageColumns];
                string[] fname = new string[ImageColumns];
                bool ArrayIsEmpty = true;
                for (int i = 0; i <= ImageColumns - 1; i++)
                {
                    img[i] = blankImage; //blankImage is a byte array with a blank image
                    caption[i] = "";
                    fname[i] = "";
                }

                int idx = 0;
                int ctr = 0;

                ImageCount = 0;
                imagesDisplayed.Clear(); //Dictionary containing image file names

                if (!noImagesInFLD)
                {
                    switch (imageExt.ToUpper())
                    {
                        case ".FLD":
                            clsFolder FLD = new clsFolder();
                            FLD.FolderName = imageAddr;
                            FLD.OpenFolder();

                            for (int i = 1; i <= FLD.FolderItems.Count; i++)
                            {
                                FolderItem fi = FLD.FolderItems.get_Item(i);

                                idx = ctr % ImageColumns;
                                ctr++;
                                caption[idx] = string.Format("Image {0}", ctr);

                                if (File.Exists(fi.FolderLiteralPath))
                                {
                                    AtLeastOneImageFound = true;
                                    fname[idx] = fi.FolderLiteralPath;

                                    img[idx] = Image.FromFile(fi.FolderLiteralPath);
                                    ImageCount++;
                                    imagesDisplayed.Add(ImageCount, fname[idx]);

                                }
                                else
                                {
                                    img[idx] = Properties.Resources.missingimage;
                                }

                                ArrayIsEmpty = false;

                                if ((idx == ImageColumns - 1)) // || FirstTimeThrough)
                                {
                                    dgvImages.Rows.Add();

                                    for (int c = 0; c <= ImageColumns - 1; c++)
                                    {
                                        dgvImages[c * 3, dgvImages.Rows.Count - 1].Value = caption[c];
                                        dgvImages[c * 3 + 1, dgvImages.Rows.Count - 1].Value = fname[c];
                                        dgvImages[c * 3 + 2, dgvImages.Rows.Count - 1].Value = img[c];
                                    }

                                    dgvImages.Rows[dgvImages.Rows.Count - 1].Height = Convert.ToInt16((4.0 / 3.0) * dgvImages.Columns[2].Width);

                                    for (int j = 0; j <= ImageColumns - 1; j++)
                                    {
                                        img[j] = blank;
                                        caption[j] = "";
                                        fname[j] = "";
                                    }
                                    ArrayIsEmpty = true;
                                }
                            }

                            if (!ArrayIsEmpty)
                            {
                                dgvImages.Rows.Add();
                                for (int c = 0; c <= ImageColumns - 1; c++)
                                {
                                    dgvImages[c * 3, dgvImages.Rows.Count - 1].Value = caption[c];
                                    dgvImages[c * 3 + 1, dgvImages.Rows.Count - 1].Value = fname[c];
                                    dgvImages[c * 3 + 2, dgvImages.Rows.Count - 1].Value = img[c];
                                }
                                dgvImages.Rows[dgvImages.Rows.Count - 1].Height = Convert.ToInt16((4.0 / 3.0) * dgvImages.Columns[2].Width);
                            }

                            break;
                        case ".JPG":
                        case ".JPEG":
                        case ".PNG":
                            dgvImages.Rows.Add();
                            dgvImages[0, dgvImages.Rows.Count - 1].Value = "Image 1";
                            dgvImages[1, dgvImages.Rows.Count - 1].Value = imageAddr ;
                            dgvImages[2, dgvImages.Rows.Count - 1].Value = Image.FromFile(imageAddr);

                            for (int c = 1; c <= ImageColumns - 1; c++)
                            {
                                dgvImages[c * 3, dgvImages.Rows.Count - 1].Value = caption[c];
                                dgvImages[c * 3 + 1, dgvImages.Rows.Count - 1].Value = fname[c];
                                dgvImages[c * 3 + 2, dgvImages.Rows.Count - 1].Value = img[c];
                            }
                            dgvImages.Rows[dgvImages.Rows.Count - 1].Height = Convert.ToInt16((4.0 / 3.0) * dgvImages.Columns[2].Width);
                            break;
                        case ".TIF":
                        case ".TIFF":
                            //This is for handling multi-page TIFF files
                            Image im = Image.FromFile(imageAddr);
                            FrameDimension dimension = FrameDimension.Page;
                            int pageCount = im.GetFrameCount(dimension);

                            pBar.Maximum = pageCount;
                            ctr = 0;

                            for (int i = 0; i <= pageCount-1; i++)
                            {

                                idx = ctr % ImageColumns;
                                ctr++;
                                caption[idx] = string.Format("Image {0}", ctr);

                                fname[idx] = string.Format("FRAME{0}",i);

                                im.SelectActiveFrame(dimension, i);

                                img[idx] = new Bitmap(im);

                                ImageCount++;
                                imagesDisplayed.Add(ImageCount, fname[idx]);

                                ArrayIsEmpty = false;

                                if ((idx == ImageColumns - 1)) // || FirstTimeThrough)
                                {
                                    dgvImages.Rows.Add();

                                    for (int c = 0; c <= ImageColumns - 1; c++)
                                    {
                                        dgvImages[c * 3, dgvImages.Rows.Count - 1].Value = caption[c];
                                        dgvImages[c * 3 + 1, dgvImages.Rows.Count - 1].Value = fname[c];
                                        dgvImages[c * 3 + 2, dgvImages.Rows.Count - 1].Value = img[c];
                                    }

                                    dgvImages.Rows[dgvImages.Rows.Count - 1].Height = Convert.ToInt16((4.0 / 3.0) * dgvImages.Columns[2].Width);

                                    for (int j = 0; j <= ImageColumns - 1; j++)
                                    {
                                        img[j] = blank;
                                        caption[j] = "";
                                        fname[j] = "";
                                    }
                                    ArrayIsEmpty = true;
                                }
                            }

                            if (!ArrayIsEmpty)
                            {
                                dgvImages.Rows.Add();
                                for (int c = 0; c <= ImageColumns - 1; c++)
                                {
                                    dgvImages[c * 3, dgvImages.Rows.Count - 1].Value = caption[c];
                                    dgvImages[c * 3 + 1, dgvImages.Rows.Count - 1].Value = fname[c];
                                    dgvImages[c * 3 + 2, dgvImages.Rows.Count - 1].Value = img[c];

                                }
                                dgvImages.Rows[dgvImages.Rows.Count - 1].Height = Convert.ToInt16((4.0 / 3.0) * dgvImages.Columns[2].Width);
                            }
                            break;
                        default:
                            break;
                    } //switch (imageExt.ToUpper())
                } //if (!noImagesInFLD)
            } //if (File.Exists(imageAddr))
        } //if (imageAddr != "")


        dgvImages.ResumeLayout(true);

    }

目前尚不清楚为什么子文件夹以大写字母P命名,因为下载的ZIP带有小写字母。无论如何,将子文件夹重命名为“私有”后,所有示例均按预期工作。