Azzera filtri
Azzera filtri

Error: Invalid parameter/value pair arguments.

42 visualizzazioni (ultimi 30 giorni)
Hi there, this code return (Invalid parameter/value pair arguments ) error. Is there any problem with using 'color'? how can I fix it?
clc
clear
close all
format long g
%% read
fid = xlsread('WINT.csv');
f = fid(:, 1);
for i = 1:size(north)
for j=1
t(i,j)=i;
end
end
Y = fft(f) ;
dt = mean(diff(t)) ;
fs = 1./(dt*24) ;
L = length(f) ;
ft = fs*(0:L/2)/L ;
P2 = abs(Y/L) ;
P1 = P2(1:L/2+1) ;
P1(2:end-1) = 2*P1(2:end-1) ;
P1 = P1.^2 ;
period = (1./ft)/24 ;
freq = 600 ;
figure
plot(ft*1e9, P1, 'color','b')
xlabel('Frequency [nHz]')
ylabel('PSD')
title('Fourier spectrum')
set(gca, 'XScale', 'log')
xline((1/(freq*24*60*60))*1e9,'color',[125,0,251]/255 , [num2str(freq), ' days'])
set(gca, 'YLim', [0, 40])

Risposta accettata

dpb
dpb il 19 Ott 2022
" Is there any problem with using 'color'?"
In
xline((1/(freq*24*60*60))*1e9,'color',[125,0,251]/255 , [num2str(freq), ' days'])
yes, there is. The named parameters for xline must follow the last of the input parameters and the second, must be a linespec character or string variable if the third for the label is used. It isn't flexible-enough in parsing inputs to mix up the order. To use a color triplet and the name as an argument, you need to write the above as
xline((1/(freq*24*60*60))*1e9,'-',[num2str(freq),' days'],'color',[125,0,251]/255)
where the linespec is the linestyle '-' character.
One slight difference that makes the name a little simpler could be to use the new(ish) string class that overloads the plus operator--
xline((1/(freq*24*60*60))*1e9,'-',freq+" days",'color',[125,0,251]/255)
NOTA BENE: the use of the " double quotes around the string constant.

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by