plotly_matlab icon indicating copy to clipboard operation
plotly_matlab copied to clipboard

Unrecognized function or variable 'toC'

Open AdamAtTrimble opened this issue 1 year ago • 4 comments

I am trying to get plotly offline working with matlab 2024a and I keep encountering the error

Unrecognized function or variable 'toC'.

Error in extractAxisData (line 90)
    tickLabels = toC(axisData.(axisName + "TickLabel"));

Error in updateAxis (line 76)
        [xaxis, xExponentFormat] = extractAxisData(obj,axisData, 'X');

Error in plotlyfig/update (line 779)
                    updateAxis(obj,n);

Error in plotlyfig (line 292)
                obj.update;

Error in fig2plotly (line 42)
    p = plotlyfig(varargin{:});

AdamAtTrimble avatar Aug 16 '24 14:08 AdamAtTrimble

If I switch to tag 2.5.5 the issue goes away. The code is also quite different in extractAxisData between the two versions

AdamAtTrimble avatar Aug 16 '24 14:08 AdamAtTrimble

I am also having the same problem. How should I implement your solution? Should I install version 2.2.5? It is quite weird that a function should be missing. Perhaps it can be easily created?

JoaoAmaro2001 avatar Sep 24 '24 11:09 JoaoAmaro2001

Try removing the toC call in toC(axisData.(axisName + "TickLabel"))

ex: tickLabels = axisData.(axisName + "TickLabel");

brburrous avatar Sep 26 '24 20:09 brburrous

I asked GPT to create the function toC and it worked. Just add it to the root dir.

function out = toC(in)
    % Converts the input into a cell array
    % Handles different data types appropriately

    if iscell(in)
        % Input is already a cell array
        out = in;
    elseif ischar(in) || isstring(in)
        % Convert character arrays or strings to cell array of strings
        out = cellstr(in);
    elseif isnumeric(in)
        % Convert numeric arrays to cell array of numbers
        out = num2cell(in);
    elseif isdatetime(in) || isduration(in)
        % Convert datetime or duration arrays to cell array of strings
        out = cellstr(in);
    elseif iscategorical(in)
        % Convert categorical arrays to cell array of strings
        out = cellstr(in);
    else
        % If the input type is unexpected, return it as is
        out = in;
    end
end

JoaoAmaro2001 avatar Oct 03 '24 20:10 JoaoAmaro2001

The issue was fixed in commit f56427e

robertoffmoura avatar Mar 02 '25 12:03 robertoffmoura