I keep getting an error message in my code

3 visualizzazioni (ultimi 30 giorni)
Gabriel
Gabriel il 21 Feb 2025
Commentato: Gabriel il 10 Mar 2025
I keep getting error message. I started out the code with the 2 lines below:
13 addpath(strcat(pwd,'\functions\')) % add path where you saved to memd function
14 save_path = strcat(pwd,'\figs\'); % path where you want to save your figures
And I keep getting the message:
Warning: Name is nonexistent or not a directory: C:\Users\Name\Downloads\functions
> In path (line 109) (line 109 is a blank in the code)
>In addpath (line 86)
In MyVersiontestcode (line 13)
noise = 0×15000 empty double matrix
Error using plot
Invalid color or line style.
Error in MyVersiontestcode (line 86)
86 plot(t,data_na(i,:),'color',col(:,i),'LineWidth',2);
-------------------------------------
Does somebody have a suggestion as to what the problem might be?
Thank you
Gabe

Risposte (1)

Walter Roberson
Walter Roberson il 21 Feb 2025
plot(t,data_na(i,:),'color',col(:,i),'LineWidth',2);
My guess is that you need
plot(t,data_na(i,:),'color',col(i,:),'LineWidth',2);
  5 Commenti
Walter Roberson
Walter Roberson il 25 Feb 2025
There is no way to plot using character vectors as coordinates.
One possibility is
plot(t,double(data_na(i,:)),'color',col(i,:),'LineWidth',2);
XT = xticks;
xlabel(cellstr(char(XT(:))))
This will treat the character entries in data_na as a vector of offsets, draw using those coordinates, and then relabel the tick positions back to the character versions. For example if data_na(i,:) were 'DEAD' then it would treat it as double(['D', 'E', 'A', 'D']) which is [68 69 65 68] and would draw using those as coordinates.
I have to wonder, however, whetherr data_na(i,:) represents categorical data? If so then something more like
plot(t, categorical(cellstr(data_na)))
would be expected, treating each row of data_na as a categorical entry.
Maybe what is going on should be converted to
pointsize = 16;
scatter(t, categorical(cellstr(data_na)), pointsize, col)
with no loop.
Gabriel
Gabriel il 10 Mar 2025
Thank you. I'll change the code and see =how it works.

Accedi per commentare.

Categorie

Scopri di più su Graphics Performance in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by