Tag Archives: matlab
Question to Matlab solve-function
Hey guys I have a simple question:
I am using Matlab R2010a and trying to solve an equation with 1 variable like this:
solve(‘4-t^2=0’)
ans =
-2
2
No problem as you can see 😉
My question is, when I try to replace the *4* with a variable (lets call it A), it wont work how I want it to work:
solve(‘A-t^2=0’)
ans =
A^(1/2)
-A^(1/2)
All fine, solution found but A is not a variable, it has a defined value of 4, so that the solution would be -2,2.
Can anyone help me to find the solution to this problem if its possible?
Thanks a lot guys!Hey guys I have a simple question:
I am using Matlab R2010a and trying to solve an equation with 1 variable like this:
solve(‘4-t^2=0’)
ans =
-2
2
No problem as you can see 😉
My question is, when I try to replace the *4* with a variable (lets call it A), it wont work how I want it to work:
solve(‘A-t^2=0’)
ans =
A^(1/2)
-A^(1/2)
All fine, solution found but A is not a variable, it has a defined value of 4, so that the solution would be -2,2.
Can anyone help me to find the solution to this problem if its possible?
Thanks a lot guys! Hey guys I have a simple question:
I am using Matlab R2010a and trying to solve an equation with 1 variable like this:
solve(‘4-t^2=0’)
ans =
-2
2
No problem as you can see 😉
My question is, when I try to replace the *4* with a variable (lets call it A), it wont work how I want it to work:
solve(‘A-t^2=0’)
ans =
A^(1/2)
-A^(1/2)
All fine, solution found but A is not a variable, it has a defined value of 4, so that the solution would be -2,2.
Can anyone help me to find the solution to this problem if its possible?
Thanks a lot guys! solve, variable MATLAB Answers — New Questions
The power trendline does not work correctly.
Power Trend line equation has the form y=ax^b, but in MATLAB Online it always appear a=b.Power Trend line equation has the form y=ax^b, but in MATLAB Online it always appear a=b. Power Trend line equation has the form y=ax^b, but in MATLAB Online it always appear a=b. power trend line MATLAB Answers — New Questions
Fitting data to a Gaussian when data is a little bit skewed (but not too much)
Hello, I have some data below that should approx to a Gaussian.
1.00 NaN
2.00 4.00
3.00 3.00
4.00 6.00
5.00 9.00
6.00 7.00
7.00 9.00
8.00 57.00
9.00 141.00
10.00 205.00
11.00 204.00
12.00 190.00
13.00 86.00
14.00 23.00
15.00 5.00
16.00 4.00
17.00 7.00
18.00 5.00
19.00 7.00
20.00 4.00
21.00 5.00
I understand its not perfect, but when I give my gaussian fitting the parameters represented by the orange curve, it fails to do any kind of fit.
This is my Routine
b0 = 11.00
c0 = 1.73 % This is actually sqrt (fwhm guess = 3)
function [fwhm,xdataFine,fitGaus,xpeak,ypeak,rsquared]=myGaussianFit2(xdata,ydata, b0,c0)
%——————–Gaussian Fit—————————————-
%Input is xdata, ydata and must be in column vector format
%only two initial guesses required as the following are determine by ydata
a0 = max(ydata(:)); %-min(ydata(:));
d0 = min(ydata(:));
%b0 is the guess at x-location of peak
%c0 is guess at width of peak
%Output gives the fitted parameters as well as xpeak location and its
%yvalue (i.e. xpeak & ypeak
%————————————————————————-
%Define Gauss Equation (remember the . notation
gaussEqn =’a*exp(-0.5*((x-b)/(c^2)).^2)+d’;
%Use startpoint to define guess values (otherwise fit doesn’t perform well)
try
%f = fit(xdata,ydata,gaussEqn,’Normalize’,’off’, ‘StartPoint’,[a0,b0,sqrt(c0),d0]); %use c^2 instred of c to enforce postive sigma/fwhm
[f,gof]=fit(xdata,ydata,gaussEqn,’Normalize’,’off’, ‘StartPoint’,[a0,b0,sqrt(c0),d0]); %use c^2 instead of c to enforce postive sigma/fwhm
coeffs=coeffvalues(f);
a=coeffs(1); b=coeffs(2);
c=coeffs(3); %need to square it as used c^2 in fitting equation to enforce +ve values
c=c^2;
d=coeffs(4);
rsquared=gof.rsquare;
fwhm=c*sqrt(log(256));
% %Increase resolution of x data (by 30)
xdataFine=(linspace(xdata(1),xdata(end),100))’;
% Create high res Gauss function
fitGaus = a*exp(-0.5*((xdataFine-b)/c).^2)+d;
%Find max value and its x location
ypeak=max(fitGaus);
xpeak=b;
xpeak=mean(xpeak(:)); %Take mean incase more than one peak found
catch
a=0;b=0;c=0;d=0;xpeak=0;ypeak=0;
end
Is there anyhting I can do here to make the fit work, although I understand its not great, but I still think it should be able to fit something!Hello, I have some data below that should approx to a Gaussian.
1.00 NaN
2.00 4.00
3.00 3.00
4.00 6.00
5.00 9.00
6.00 7.00
7.00 9.00
8.00 57.00
9.00 141.00
10.00 205.00
11.00 204.00
12.00 190.00
13.00 86.00
14.00 23.00
15.00 5.00
16.00 4.00
17.00 7.00
18.00 5.00
19.00 7.00
20.00 4.00
21.00 5.00
I understand its not perfect, but when I give my gaussian fitting the parameters represented by the orange curve, it fails to do any kind of fit.
This is my Routine
b0 = 11.00
c0 = 1.73 % This is actually sqrt (fwhm guess = 3)
function [fwhm,xdataFine,fitGaus,xpeak,ypeak,rsquared]=myGaussianFit2(xdata,ydata, b0,c0)
%——————–Gaussian Fit—————————————-
%Input is xdata, ydata and must be in column vector format
%only two initial guesses required as the following are determine by ydata
a0 = max(ydata(:)); %-min(ydata(:));
d0 = min(ydata(:));
%b0 is the guess at x-location of peak
%c0 is guess at width of peak
%Output gives the fitted parameters as well as xpeak location and its
%yvalue (i.e. xpeak & ypeak
%————————————————————————-
%Define Gauss Equation (remember the . notation
gaussEqn =’a*exp(-0.5*((x-b)/(c^2)).^2)+d’;
%Use startpoint to define guess values (otherwise fit doesn’t perform well)
try
%f = fit(xdata,ydata,gaussEqn,’Normalize’,’off’, ‘StartPoint’,[a0,b0,sqrt(c0),d0]); %use c^2 instred of c to enforce postive sigma/fwhm
[f,gof]=fit(xdata,ydata,gaussEqn,’Normalize’,’off’, ‘StartPoint’,[a0,b0,sqrt(c0),d0]); %use c^2 instead of c to enforce postive sigma/fwhm
coeffs=coeffvalues(f);
a=coeffs(1); b=coeffs(2);
c=coeffs(3); %need to square it as used c^2 in fitting equation to enforce +ve values
c=c^2;
d=coeffs(4);
rsquared=gof.rsquare;
fwhm=c*sqrt(log(256));
% %Increase resolution of x data (by 30)
xdataFine=(linspace(xdata(1),xdata(end),100))’;
% Create high res Gauss function
fitGaus = a*exp(-0.5*((xdataFine-b)/c).^2)+d;
%Find max value and its x location
ypeak=max(fitGaus);
xpeak=b;
xpeak=mean(xpeak(:)); %Take mean incase more than one peak found
catch
a=0;b=0;c=0;d=0;xpeak=0;ypeak=0;
end
Is there anyhting I can do here to make the fit work, although I understand its not great, but I still think it should be able to fit something! Hello, I have some data below that should approx to a Gaussian.
1.00 NaN
2.00 4.00
3.00 3.00
4.00 6.00
5.00 9.00
6.00 7.00
7.00 9.00
8.00 57.00
9.00 141.00
10.00 205.00
11.00 204.00
12.00 190.00
13.00 86.00
14.00 23.00
15.00 5.00
16.00 4.00
17.00 7.00
18.00 5.00
19.00 7.00
20.00 4.00
21.00 5.00
I understand its not perfect, but when I give my gaussian fitting the parameters represented by the orange curve, it fails to do any kind of fit.
This is my Routine
b0 = 11.00
c0 = 1.73 % This is actually sqrt (fwhm guess = 3)
function [fwhm,xdataFine,fitGaus,xpeak,ypeak,rsquared]=myGaussianFit2(xdata,ydata, b0,c0)
%——————–Gaussian Fit—————————————-
%Input is xdata, ydata and must be in column vector format
%only two initial guesses required as the following are determine by ydata
a0 = max(ydata(:)); %-min(ydata(:));
d0 = min(ydata(:));
%b0 is the guess at x-location of peak
%c0 is guess at width of peak
%Output gives the fitted parameters as well as xpeak location and its
%yvalue (i.e. xpeak & ypeak
%————————————————————————-
%Define Gauss Equation (remember the . notation
gaussEqn =’a*exp(-0.5*((x-b)/(c^2)).^2)+d’;
%Use startpoint to define guess values (otherwise fit doesn’t perform well)
try
%f = fit(xdata,ydata,gaussEqn,’Normalize’,’off’, ‘StartPoint’,[a0,b0,sqrt(c0),d0]); %use c^2 instred of c to enforce postive sigma/fwhm
[f,gof]=fit(xdata,ydata,gaussEqn,’Normalize’,’off’, ‘StartPoint’,[a0,b0,sqrt(c0),d0]); %use c^2 instead of c to enforce postive sigma/fwhm
coeffs=coeffvalues(f);
a=coeffs(1); b=coeffs(2);
c=coeffs(3); %need to square it as used c^2 in fitting equation to enforce +ve values
c=c^2;
d=coeffs(4);
rsquared=gof.rsquare;
fwhm=c*sqrt(log(256));
% %Increase resolution of x data (by 30)
xdataFine=(linspace(xdata(1),xdata(end),100))’;
% Create high res Gauss function
fitGaus = a*exp(-0.5*((xdataFine-b)/c).^2)+d;
%Find max value and its x location
ypeak=max(fitGaus);
xpeak=b;
xpeak=mean(xpeak(:)); %Take mean incase more than one peak found
catch
a=0;b=0;c=0;d=0;xpeak=0;ypeak=0;
end
Is there anyhting I can do here to make the fit work, although I understand its not great, but I still think it should be able to fit something! fit, gaussian MATLAB Answers — New Questions
About the DeLong test
Dear Professors,
I apologize for bothering you during your busy schedules. We have conducted the program described below, reading three files and performing ROC analysis through machine learning to calculate three AUCs. We have attempted to create a program to demonstrate the statistical significance of the differences among these AUCs, but despite multiple efforts, we have encountered errors that prevent progress. Could you please help us revise the program? I am attaching a program below. I would greatly appreciate it if you could add the necessary modifications to it. I am having a lot of trouble implementing the DeLong test in the program. Thank you very much for your assistance.Thank you very much for your assistance.
Best regards,
% CSVファイルのパスを指定
filePaths = {‘C:Usersrms56Desktop1-491B.csv’, …
‘C:Usersrms56Desktop1-491C.csv’, …
‘C:Usersrms56Desktop1-491D.csv’};
% X と y を格納するための cell 配列を作成
X_all = cell(3, 1); % 特徴量 X 用の cell 配列
y_all = cell(3, 1); % ラベル y 用の cell 配列
% 3つのファイルを順番に読み込み、X と y に割り当てる
for i = 1:3
% CSVファイルの読み込み
data = readmatrix(filePaths{i});
% 各ファイルに応じて X と y の列を指定
if i == 1 % ‘1-491B.csv’: 3列目までがX、4列目がY
X_all{i} = data(:, 1:3); % 1~3列目を X に設定
y_all{i} = data(:, 4); % 4列目を Y に設定
elseif i == 2 % ‘1-491C.csv’: 6列目までがX、7列目がY
X_all{i} = data(:, 1:6); % 1~6列目を X に設定
y_all{i} = data(:, 7); % 7列目を Y に設定
elseif i == 3 % ‘1-491D.csv’: 3列目までがX、4列目がY
X_all{i} = data(:, 1:3); % 1~3列目を X に設定
y_all{i} = data(:, 4); % 4列目を Y に設定
end
end
% ファイルごとの解析をループで実行
for fileIndex = 1:3
% ファイルに対応するデータを取得
X = X_all{fileIndex}; % 特徴量
y = y_all{fileIndex}; % ラベル
% クロスバリデーションの設定
k = 5; % フォールド数
cv = cvpartition(y, ‘KFold’, k); % クロスバリデーションの分割
accuracy = zeros(k, 1); % 各フォールドの精度を格納する配列
% 各フォールドごとにトレーニングとテストを実行
for i = 1:k
trainIdx = training(cv, i);
testIdx = test(cv, i);
% データの分割
XTrain = X(trainIdx, :);
yTrain = y(trainIdx, :);
XTest = X(testIdx, :);
yTest = y(testIdx, :);
% SVMモデルのトレーニング
model = fitcsvm(XTrain, yTrain, …
‘KernelFunction’, ‘polynomial’, …
‘PolynomialOrder’, 2, …
‘KernelScale’, ‘auto’, …
‘BoxConstraint’, 1, …
‘Standardize’, true);
% モデルを使用してテストセットを予測
[predictions, score] = predict(model, XTest);
% 現在のフォールドの精度を計算
accuracy(i) = sum(predictions == yTest) / length(yTest);
fprintf(‘ファイル %d – Fold %d Accuracy: %.2f%%n’, fileIndex, i, accuracy(i) * 100);
end
% 全フォールドの平均精度を計算
averageAccuracy = mean(accuracy);
fprintf(‘ファイル %d – Average Accuracy: %.2f%%n’, fileIndex, averageAccuracy * 100);
% ROC曲線とAUCの計算
[~, ~, ~, AUC_final] = perfcurve(yTest, score(:, 2), 1);
% ブートストラップ法で信頼区間を計算
nBoot = 1000; % ブートストラップの反復回数
[AUC_bootstrap, CI_final] = bootstrapAUC(yTest, score(:, 2), nBoot);
% 混同行列の計算
confusionMatrix_final = confusionmat(yTest, predictions);
tn = confusionMatrix_final(1, 1);
fp = confusionMatrix_final(1, 2);
fn = confusionMatrix_final(2, 1);
tp = confusionMatrix_final(2, 2);
% 指標の計算
sensitivity_final = tp / (tp + fn);
specificity_final = tn / (tn + fp);
ppv_final = tp / (tp + fp);
npv_final = tn / (tn + fn);
accuracy_final = (tp + tn) / sum(confusionMatrix_final(:));
% 結果の表示
fprintf(‘ファイル %d – 最終的なAUC: %.2fn’, fileIndex, AUC_final);
fprintf(‘ファイル %d – ブートストラップ法による95%%信頼区間: [%.2f, %.2f]n’, fileIndex, CI_final(1), CI_final(2));
fprintf(‘感度: %.2fn’, sensitivity_final);
fprintf(‘特異度: %.2fn’, specificity_final);
fprintf(‘陽性的中率: %.2fn’, ppv_final);
fprintf(‘陰性的中率: %.2fn’, npv_final);
fprintf(‘診断精度: %.2fn’, accuracy_final);
% ROC曲線を描画
figure;
plot(Xroc, Yroc, ‘b-‘, ‘LineWidth’, 2);
xlabel(‘特異度’);
ylabel(‘感度’);
title(sprintf(‘ファイル %d – ROC曲線’, fileIndex));
grid on;
% 混同行列を描画
figure;
confusionchart(confusionMatrix_final, {‘Negative’, ‘Positive’}, ‘RowSummary’, ‘row-normalized’, …
‘ColumnSummary’, ‘column-normalized’);
title(sprintf(‘ファイル %d – 混同行列’, fileIndex));
end
% ブートストラップ法によるAUCと信頼区間を計算する関数
function [AUC, CI] = bootstrapAUC(yTrue, scores, nBoot)
% 初期化
AUC = zeros(nBoot, 1);
for i = 1:nBoot
idx = randi(length(yTrue), [length(yTrue), 1]); % リプレースメントで再サンプリング
yBoot = yTrue(idx);
scoresBoot = scores(idx);
[~, ~, ~, AUC(i)] = perfcurve(yBoot, scoresBoot, 1); % AUC計算
end
% 信頼区間の計算
CI = prctile(AUC, [2.5 97.5]); % 95%信頼区間
endDear Professors,
I apologize for bothering you during your busy schedules. We have conducted the program described below, reading three files and performing ROC analysis through machine learning to calculate three AUCs. We have attempted to create a program to demonstrate the statistical significance of the differences among these AUCs, but despite multiple efforts, we have encountered errors that prevent progress. Could you please help us revise the program? I am attaching a program below. I would greatly appreciate it if you could add the necessary modifications to it. I am having a lot of trouble implementing the DeLong test in the program. Thank you very much for your assistance.Thank you very much for your assistance.
Best regards,
% CSVファイルのパスを指定
filePaths = {‘C:Usersrms56Desktop1-491B.csv’, …
‘C:Usersrms56Desktop1-491C.csv’, …
‘C:Usersrms56Desktop1-491D.csv’};
% X と y を格納するための cell 配列を作成
X_all = cell(3, 1); % 特徴量 X 用の cell 配列
y_all = cell(3, 1); % ラベル y 用の cell 配列
% 3つのファイルを順番に読み込み、X と y に割り当てる
for i = 1:3
% CSVファイルの読み込み
data = readmatrix(filePaths{i});
% 各ファイルに応じて X と y の列を指定
if i == 1 % ‘1-491B.csv’: 3列目までがX、4列目がY
X_all{i} = data(:, 1:3); % 1~3列目を X に設定
y_all{i} = data(:, 4); % 4列目を Y に設定
elseif i == 2 % ‘1-491C.csv’: 6列目までがX、7列目がY
X_all{i} = data(:, 1:6); % 1~6列目を X に設定
y_all{i} = data(:, 7); % 7列目を Y に設定
elseif i == 3 % ‘1-491D.csv’: 3列目までがX、4列目がY
X_all{i} = data(:, 1:3); % 1~3列目を X に設定
y_all{i} = data(:, 4); % 4列目を Y に設定
end
end
% ファイルごとの解析をループで実行
for fileIndex = 1:3
% ファイルに対応するデータを取得
X = X_all{fileIndex}; % 特徴量
y = y_all{fileIndex}; % ラベル
% クロスバリデーションの設定
k = 5; % フォールド数
cv = cvpartition(y, ‘KFold’, k); % クロスバリデーションの分割
accuracy = zeros(k, 1); % 各フォールドの精度を格納する配列
% 各フォールドごとにトレーニングとテストを実行
for i = 1:k
trainIdx = training(cv, i);
testIdx = test(cv, i);
% データの分割
XTrain = X(trainIdx, :);
yTrain = y(trainIdx, :);
XTest = X(testIdx, :);
yTest = y(testIdx, :);
% SVMモデルのトレーニング
model = fitcsvm(XTrain, yTrain, …
‘KernelFunction’, ‘polynomial’, …
‘PolynomialOrder’, 2, …
‘KernelScale’, ‘auto’, …
‘BoxConstraint’, 1, …
‘Standardize’, true);
% モデルを使用してテストセットを予測
[predictions, score] = predict(model, XTest);
% 現在のフォールドの精度を計算
accuracy(i) = sum(predictions == yTest) / length(yTest);
fprintf(‘ファイル %d – Fold %d Accuracy: %.2f%%n’, fileIndex, i, accuracy(i) * 100);
end
% 全フォールドの平均精度を計算
averageAccuracy = mean(accuracy);
fprintf(‘ファイル %d – Average Accuracy: %.2f%%n’, fileIndex, averageAccuracy * 100);
% ROC曲線とAUCの計算
[~, ~, ~, AUC_final] = perfcurve(yTest, score(:, 2), 1);
% ブートストラップ法で信頼区間を計算
nBoot = 1000; % ブートストラップの反復回数
[AUC_bootstrap, CI_final] = bootstrapAUC(yTest, score(:, 2), nBoot);
% 混同行列の計算
confusionMatrix_final = confusionmat(yTest, predictions);
tn = confusionMatrix_final(1, 1);
fp = confusionMatrix_final(1, 2);
fn = confusionMatrix_final(2, 1);
tp = confusionMatrix_final(2, 2);
% 指標の計算
sensitivity_final = tp / (tp + fn);
specificity_final = tn / (tn + fp);
ppv_final = tp / (tp + fp);
npv_final = tn / (tn + fn);
accuracy_final = (tp + tn) / sum(confusionMatrix_final(:));
% 結果の表示
fprintf(‘ファイル %d – 最終的なAUC: %.2fn’, fileIndex, AUC_final);
fprintf(‘ファイル %d – ブートストラップ法による95%%信頼区間: [%.2f, %.2f]n’, fileIndex, CI_final(1), CI_final(2));
fprintf(‘感度: %.2fn’, sensitivity_final);
fprintf(‘特異度: %.2fn’, specificity_final);
fprintf(‘陽性的中率: %.2fn’, ppv_final);
fprintf(‘陰性的中率: %.2fn’, npv_final);
fprintf(‘診断精度: %.2fn’, accuracy_final);
% ROC曲線を描画
figure;
plot(Xroc, Yroc, ‘b-‘, ‘LineWidth’, 2);
xlabel(‘特異度’);
ylabel(‘感度’);
title(sprintf(‘ファイル %d – ROC曲線’, fileIndex));
grid on;
% 混同行列を描画
figure;
confusionchart(confusionMatrix_final, {‘Negative’, ‘Positive’}, ‘RowSummary’, ‘row-normalized’, …
‘ColumnSummary’, ‘column-normalized’);
title(sprintf(‘ファイル %d – 混同行列’, fileIndex));
end
% ブートストラップ法によるAUCと信頼区間を計算する関数
function [AUC, CI] = bootstrapAUC(yTrue, scores, nBoot)
% 初期化
AUC = zeros(nBoot, 1);
for i = 1:nBoot
idx = randi(length(yTrue), [length(yTrue), 1]); % リプレースメントで再サンプリング
yBoot = yTrue(idx);
scoresBoot = scores(idx);
[~, ~, ~, AUC(i)] = perfcurve(yBoot, scoresBoot, 1); % AUC計算
end
% 信頼区間の計算
CI = prctile(AUC, [2.5 97.5]); % 95%信頼区間
end Dear Professors,
I apologize for bothering you during your busy schedules. We have conducted the program described below, reading three files and performing ROC analysis through machine learning to calculate three AUCs. We have attempted to create a program to demonstrate the statistical significance of the differences among these AUCs, but despite multiple efforts, we have encountered errors that prevent progress. Could you please help us revise the program? I am attaching a program below. I would greatly appreciate it if you could add the necessary modifications to it. I am having a lot of trouble implementing the DeLong test in the program. Thank you very much for your assistance.Thank you very much for your assistance.
Best regards,
% CSVファイルのパスを指定
filePaths = {‘C:Usersrms56Desktop1-491B.csv’, …
‘C:Usersrms56Desktop1-491C.csv’, …
‘C:Usersrms56Desktop1-491D.csv’};
% X と y を格納するための cell 配列を作成
X_all = cell(3, 1); % 特徴量 X 用の cell 配列
y_all = cell(3, 1); % ラベル y 用の cell 配列
% 3つのファイルを順番に読み込み、X と y に割り当てる
for i = 1:3
% CSVファイルの読み込み
data = readmatrix(filePaths{i});
% 各ファイルに応じて X と y の列を指定
if i == 1 % ‘1-491B.csv’: 3列目までがX、4列目がY
X_all{i} = data(:, 1:3); % 1~3列目を X に設定
y_all{i} = data(:, 4); % 4列目を Y に設定
elseif i == 2 % ‘1-491C.csv’: 6列目までがX、7列目がY
X_all{i} = data(:, 1:6); % 1~6列目を X に設定
y_all{i} = data(:, 7); % 7列目を Y に設定
elseif i == 3 % ‘1-491D.csv’: 3列目までがX、4列目がY
X_all{i} = data(:, 1:3); % 1~3列目を X に設定
y_all{i} = data(:, 4); % 4列目を Y に設定
end
end
% ファイルごとの解析をループで実行
for fileIndex = 1:3
% ファイルに対応するデータを取得
X = X_all{fileIndex}; % 特徴量
y = y_all{fileIndex}; % ラベル
% クロスバリデーションの設定
k = 5; % フォールド数
cv = cvpartition(y, ‘KFold’, k); % クロスバリデーションの分割
accuracy = zeros(k, 1); % 各フォールドの精度を格納する配列
% 各フォールドごとにトレーニングとテストを実行
for i = 1:k
trainIdx = training(cv, i);
testIdx = test(cv, i);
% データの分割
XTrain = X(trainIdx, :);
yTrain = y(trainIdx, :);
XTest = X(testIdx, :);
yTest = y(testIdx, :);
% SVMモデルのトレーニング
model = fitcsvm(XTrain, yTrain, …
‘KernelFunction’, ‘polynomial’, …
‘PolynomialOrder’, 2, …
‘KernelScale’, ‘auto’, …
‘BoxConstraint’, 1, …
‘Standardize’, true);
% モデルを使用してテストセットを予測
[predictions, score] = predict(model, XTest);
% 現在のフォールドの精度を計算
accuracy(i) = sum(predictions == yTest) / length(yTest);
fprintf(‘ファイル %d – Fold %d Accuracy: %.2f%%n’, fileIndex, i, accuracy(i) * 100);
end
% 全フォールドの平均精度を計算
averageAccuracy = mean(accuracy);
fprintf(‘ファイル %d – Average Accuracy: %.2f%%n’, fileIndex, averageAccuracy * 100);
% ROC曲線とAUCの計算
[~, ~, ~, AUC_final] = perfcurve(yTest, score(:, 2), 1);
% ブートストラップ法で信頼区間を計算
nBoot = 1000; % ブートストラップの反復回数
[AUC_bootstrap, CI_final] = bootstrapAUC(yTest, score(:, 2), nBoot);
% 混同行列の計算
confusionMatrix_final = confusionmat(yTest, predictions);
tn = confusionMatrix_final(1, 1);
fp = confusionMatrix_final(1, 2);
fn = confusionMatrix_final(2, 1);
tp = confusionMatrix_final(2, 2);
% 指標の計算
sensitivity_final = tp / (tp + fn);
specificity_final = tn / (tn + fp);
ppv_final = tp / (tp + fp);
npv_final = tn / (tn + fn);
accuracy_final = (tp + tn) / sum(confusionMatrix_final(:));
% 結果の表示
fprintf(‘ファイル %d – 最終的なAUC: %.2fn’, fileIndex, AUC_final);
fprintf(‘ファイル %d – ブートストラップ法による95%%信頼区間: [%.2f, %.2f]n’, fileIndex, CI_final(1), CI_final(2));
fprintf(‘感度: %.2fn’, sensitivity_final);
fprintf(‘特異度: %.2fn’, specificity_final);
fprintf(‘陽性的中率: %.2fn’, ppv_final);
fprintf(‘陰性的中率: %.2fn’, npv_final);
fprintf(‘診断精度: %.2fn’, accuracy_final);
% ROC曲線を描画
figure;
plot(Xroc, Yroc, ‘b-‘, ‘LineWidth’, 2);
xlabel(‘特異度’);
ylabel(‘感度’);
title(sprintf(‘ファイル %d – ROC曲線’, fileIndex));
grid on;
% 混同行列を描画
figure;
confusionchart(confusionMatrix_final, {‘Negative’, ‘Positive’}, ‘RowSummary’, ‘row-normalized’, …
‘ColumnSummary’, ‘column-normalized’);
title(sprintf(‘ファイル %d – 混同行列’, fileIndex));
end
% ブートストラップ法によるAUCと信頼区間を計算する関数
function [AUC, CI] = bootstrapAUC(yTrue, scores, nBoot)
% 初期化
AUC = zeros(nBoot, 1);
for i = 1:nBoot
idx = randi(length(yTrue), [length(yTrue), 1]); % リプレースメントで再サンプリング
yBoot = yTrue(idx);
scoresBoot = scores(idx);
[~, ~, ~, AUC(i)] = perfcurve(yBoot, scoresBoot, 1); % AUC計算
end
% 信頼区間の計算
CI = prctile(AUC, [2.5 97.5]); % 95%信頼区間
end delong test MATLAB Answers — New Questions
USRP X310 Validate Radio Setup Error
I used ‘Wireless testbench Support package for NI USRP Radios’ for configuring my NI USRP-2954R, and I met the following error in the validate tap.
How can I solve this problem?I used ‘Wireless testbench Support package for NI USRP Radios’ for configuring my NI USRP-2954R, and I met the following error in the validate tap.
How can I solve this problem? I used ‘Wireless testbench Support package for NI USRP Radios’ for configuring my NI USRP-2954R, and I met the following error in the validate tap.
How can I solve this problem? toolbox, usrp, x310 MATLAB Answers — New Questions
How can I extract heart rate and respiration rate from radar signals?
Following is my matlab code. Two radar transmitters and on receiver is used. I want to combine the correlation results and extract heart beat and respiration rate. Any help?
% Initialize variables
Fs = 100; % Sampling frequency
duration = 60; % Duration of the recording in seconds
t = 0:1/Fs:duration-1/Fs; % Time vector
N = length(t); % Number of samples
f = (0:N-1)*(Fs/N); % Frequency vector
num_iterations = 10; % Number of iterations to run the code
% Initialize arrays to store heart rate and respiration rate
HR_radar = zeros(1,num_iterations);
RR_radar = zeros(1,num_iterations);
HR_ecg = zeros(1,num_iterations);
RR_ecg = zeros(1,num_iterations);
for i = 1:num_iterations
% Generate a synthetic UWB radar signal
tx1 = 0.5*sin(2*pi*1*t); % Transmitter 1 signal
tx2 = 0.5*sin(2*pi*1*t + pi); % Transmitter 2 signal
rx = tx1 + tx2; % Receiver signal
% Add noise to the receiver signal
rx = rx + 0.1*randn(size(rx));
% Filter the receiver signal to remove noise
[b,a] = butter(2, [0.5 5]/(Fs/2), ‘bandpass’);
rx_filtered = filtfilt(b,a,rx);
% Perform cross-correlation between the transmitter signals and the receiver signal
corr1 = xcorr(tx1, rx_filtered);
corr2 = xcorr(tx2, rx_filtered);
% CombineFollowing is my matlab code. Two radar transmitters and on receiver is used. I want to combine the correlation results and extract heart beat and respiration rate. Any help?
% Initialize variables
Fs = 100; % Sampling frequency
duration = 60; % Duration of the recording in seconds
t = 0:1/Fs:duration-1/Fs; % Time vector
N = length(t); % Number of samples
f = (0:N-1)*(Fs/N); % Frequency vector
num_iterations = 10; % Number of iterations to run the code
% Initialize arrays to store heart rate and respiration rate
HR_radar = zeros(1,num_iterations);
RR_radar = zeros(1,num_iterations);
HR_ecg = zeros(1,num_iterations);
RR_ecg = zeros(1,num_iterations);
for i = 1:num_iterations
% Generate a synthetic UWB radar signal
tx1 = 0.5*sin(2*pi*1*t); % Transmitter 1 signal
tx2 = 0.5*sin(2*pi*1*t + pi); % Transmitter 2 signal
rx = tx1 + tx2; % Receiver signal
% Add noise to the receiver signal
rx = rx + 0.1*randn(size(rx));
% Filter the receiver signal to remove noise
[b,a] = butter(2, [0.5 5]/(Fs/2), ‘bandpass’);
rx_filtered = filtfilt(b,a,rx);
% Perform cross-correlation between the transmitter signals and the receiver signal
corr1 = xcorr(tx1, rx_filtered);
corr2 = xcorr(tx2, rx_filtered);
% Combine Following is my matlab code. Two radar transmitters and on receiver is used. I want to combine the correlation results and extract heart beat and respiration rate. Any help?
% Initialize variables
Fs = 100; % Sampling frequency
duration = 60; % Duration of the recording in seconds
t = 0:1/Fs:duration-1/Fs; % Time vector
N = length(t); % Number of samples
f = (0:N-1)*(Fs/N); % Frequency vector
num_iterations = 10; % Number of iterations to run the code
% Initialize arrays to store heart rate and respiration rate
HR_radar = zeros(1,num_iterations);
RR_radar = zeros(1,num_iterations);
HR_ecg = zeros(1,num_iterations);
RR_ecg = zeros(1,num_iterations);
for i = 1:num_iterations
% Generate a synthetic UWB radar signal
tx1 = 0.5*sin(2*pi*1*t); % Transmitter 1 signal
tx2 = 0.5*sin(2*pi*1*t + pi); % Transmitter 2 signal
rx = tx1 + tx2; % Receiver signal
% Add noise to the receiver signal
rx = rx + 0.1*randn(size(rx));
% Filter the receiver signal to remove noise
[b,a] = butter(2, [0.5 5]/(Fs/2), ‘bandpass’);
rx_filtered = filtfilt(b,a,rx);
% Perform cross-correlation between the transmitter signals and the receiver signal
corr1 = xcorr(tx1, rx_filtered);
corr2 = xcorr(tx2, rx_filtered);
% Combine remote health monitoring MATLAB Answers — New Questions
How do I set the threshold value on the action potential on the upward and downward slope to define width?
Hi,
I am doing action potential analysis and at the moment I am defining my threshold value manually using ginput for analysing width, however I would like to set identical y values for analysis of width of the curve. Right now, I zoom into the figure to try and set the x and y points to get the width of the AP.
My code for producing the figure and setting ginput values manually for the defined variables:
% Roksana’s script to plot .smr AP data
% 20210127
% For troubleshooting analysis – cleans the workspace
clear
close all
%Import data
load(‘C:xyz.mat’)
%Define channel to plot
data = xyz;
vm = data.values;
%scale x-axis by interval
t = linspace(0, length(vm)*data.interval,length(vm));
plot(t,vm)
xlabel(‘Time (s)’)
ylabel(‘Voltage (mV)’)
title(‘Membrane potential’)
%find max Vm value between 2 points selected on the figure
[x, y] = ginput(2);
%Report values towards AP width
xfirst = x(1,1)
xsecond = x(2,1)
%Round values for calculations of parameters
xpt1 = round(x(1));
xpt2 = round(x(2));
ypt1 = round(y(1));
ypt2 = round(y(2));
%Find a point between the first and second points on x-axis
isin = (t >= xpt1 & t <= xpt2);
%Identify the peak between the two points on the x-axis
%peak = max(vm(isin))
peak = max(vm)
%Display trough (mV); from baseline
APtrough = min(vm(isin))
%%Display AP amplitude (mV)
APamp = (peak + (ypt1*(-1)))
%%Display half-amplitude(mV)
APhalfamp = ((peak-APtrough)*0.5)
%%%Area under the curve and width values from threshold value – require zoom%%%
%pause script until button press for zooming in
zoom on;
pause ();
zoom off;
%find max Vm value between 2 points selected on the figure
[a, b] = ginput(2);
%Report values towards AP width
thresholdt1 = a(1,1)
thresholdt2 = a(2,1)
thresholdValue1 = b(1)
thresholdValue2 = b(2)
%%Display width(ms)
width = (thresholdt2 – thresholdt1)*1000 %%%%needs to be defined by threshold
%%Display half-width(ms)
APhalfwidth = (width/2)Hi,
I am doing action potential analysis and at the moment I am defining my threshold value manually using ginput for analysing width, however I would like to set identical y values for analysis of width of the curve. Right now, I zoom into the figure to try and set the x and y points to get the width of the AP.
My code for producing the figure and setting ginput values manually for the defined variables:
% Roksana’s script to plot .smr AP data
% 20210127
% For troubleshooting analysis – cleans the workspace
clear
close all
%Import data
load(‘C:xyz.mat’)
%Define channel to plot
data = xyz;
vm = data.values;
%scale x-axis by interval
t = linspace(0, length(vm)*data.interval,length(vm));
plot(t,vm)
xlabel(‘Time (s)’)
ylabel(‘Voltage (mV)’)
title(‘Membrane potential’)
%find max Vm value between 2 points selected on the figure
[x, y] = ginput(2);
%Report values towards AP width
xfirst = x(1,1)
xsecond = x(2,1)
%Round values for calculations of parameters
xpt1 = round(x(1));
xpt2 = round(x(2));
ypt1 = round(y(1));
ypt2 = round(y(2));
%Find a point between the first and second points on x-axis
isin = (t >= xpt1 & t <= xpt2);
%Identify the peak between the two points on the x-axis
%peak = max(vm(isin))
peak = max(vm)
%Display trough (mV); from baseline
APtrough = min(vm(isin))
%%Display AP amplitude (mV)
APamp = (peak + (ypt1*(-1)))
%%Display half-amplitude(mV)
APhalfamp = ((peak-APtrough)*0.5)
%%%Area under the curve and width values from threshold value – require zoom%%%
%pause script until button press for zooming in
zoom on;
pause ();
zoom off;
%find max Vm value between 2 points selected on the figure
[a, b] = ginput(2);
%Report values towards AP width
thresholdt1 = a(1,1)
thresholdt2 = a(2,1)
thresholdValue1 = b(1)
thresholdValue2 = b(2)
%%Display width(ms)
width = (thresholdt2 – thresholdt1)*1000 %%%%needs to be defined by threshold
%%Display half-width(ms)
APhalfwidth = (width/2) Hi,
I am doing action potential analysis and at the moment I am defining my threshold value manually using ginput for analysing width, however I would like to set identical y values for analysis of width of the curve. Right now, I zoom into the figure to try and set the x and y points to get the width of the AP.
My code for producing the figure and setting ginput values manually for the defined variables:
% Roksana’s script to plot .smr AP data
% 20210127
% For troubleshooting analysis – cleans the workspace
clear
close all
%Import data
load(‘C:xyz.mat’)
%Define channel to plot
data = xyz;
vm = data.values;
%scale x-axis by interval
t = linspace(0, length(vm)*data.interval,length(vm));
plot(t,vm)
xlabel(‘Time (s)’)
ylabel(‘Voltage (mV)’)
title(‘Membrane potential’)
%find max Vm value between 2 points selected on the figure
[x, y] = ginput(2);
%Report values towards AP width
xfirst = x(1,1)
xsecond = x(2,1)
%Round values for calculations of parameters
xpt1 = round(x(1));
xpt2 = round(x(2));
ypt1 = round(y(1));
ypt2 = round(y(2));
%Find a point between the first and second points on x-axis
isin = (t >= xpt1 & t <= xpt2);
%Identify the peak between the two points on the x-axis
%peak = max(vm(isin))
peak = max(vm)
%Display trough (mV); from baseline
APtrough = min(vm(isin))
%%Display AP amplitude (mV)
APamp = (peak + (ypt1*(-1)))
%%Display half-amplitude(mV)
APhalfamp = ((peak-APtrough)*0.5)
%%%Area under the curve and width values from threshold value – require zoom%%%
%pause script until button press for zooming in
zoom on;
pause ();
zoom off;
%find max Vm value between 2 points selected on the figure
[a, b] = ginput(2);
%Report values towards AP width
thresholdt1 = a(1,1)
thresholdt2 = a(2,1)
thresholdValue1 = b(1)
thresholdValue2 = b(2)
%%Display width(ms)
width = (thresholdt2 – thresholdt1)*1000 %%%%needs to be defined by threshold
%%Display half-width(ms)
APhalfwidth = (width/2) action potential analysis, threshold value MATLAB Answers — New Questions
Enabling bus sorting by name in the Simulink Type Editor
How to enable bus sorting by name in the Simulink Type Editor?How to enable bus sorting by name in the Simulink Type Editor? How to enable bus sorting by name in the Simulink Type Editor? type editor, bus, gui, bus sorting MATLAB Answers — New Questions
how to change size of simscape models
When I change Stewart platform to 10 times of the default size(such as 28cm to 280 cm) and run the model, the model fell apart and became inffective. So I’d like to know is there any parameter that I need to change to make sure this model works well when its size changes.The default size is so tiny that I can use this model directly.
I’ll appreciate it if anyone could answer my little question!
Sincerely,When I change Stewart platform to 10 times of the default size(such as 28cm to 280 cm) and run the model, the model fell apart and became inffective. So I’d like to know is there any parameter that I need to change to make sure this model works well when its size changes.The default size is so tiny that I can use this model directly.
I’ll appreciate it if anyone could answer my little question!
Sincerely, When I change Stewart platform to 10 times of the default size(such as 28cm to 280 cm) and run the model, the model fell apart and became inffective. So I’d like to know is there any parameter that I need to change to make sure this model works well when its size changes.The default size is so tiny that I can use this model directly.
I’ll appreciate it if anyone could answer my little question!
Sincerely, simscape, stewart platform, simscape multibody MATLAB Answers — New Questions
FMU Export – Model Exchange & Co-Simulation
Dear Sir or Madam,
I have recently seen that FMU exportation under Model Exchange option has been included in MATLAB R2024b release.
I am trying to export a Simulink model as FMU – Model Exchange using the command:
exportToFMU(SimulinkModelName, ‘FMIVersion’, ‘2.0’, ‘FMUType’, ‘ME’)
However, I get the following error:
The make command returned an error of 2
Build Summary
Top model targets:
Model Build Reason Status
====================================================================================================================
SimulinkModelName Information cache folder or artifacts were missing. Failed to build. For more information, see build log.
0 of 1 models built (0 models already up to date)
Build duration: 0h 0m 27.437s
Error using exportFMU_ME (line 36)
Error(s) encountered while building "SimulinkModelName"
I had successfully exported this same model as FMU – CoSimulation.
exportToFMU2CS(SimulinkModelName)
Why is it possible to export the model under the CoSimulation option and not under the Model Exchange option?
Thank you very much in advance.
Best regards,
Víctor Sánchez Suárez
Norvento Enerxía S.L.Dear Sir or Madam,
I have recently seen that FMU exportation under Model Exchange option has been included in MATLAB R2024b release.
I am trying to export a Simulink model as FMU – Model Exchange using the command:
exportToFMU(SimulinkModelName, ‘FMIVersion’, ‘2.0’, ‘FMUType’, ‘ME’)
However, I get the following error:
The make command returned an error of 2
Build Summary
Top model targets:
Model Build Reason Status
====================================================================================================================
SimulinkModelName Information cache folder or artifacts were missing. Failed to build. For more information, see build log.
0 of 1 models built (0 models already up to date)
Build duration: 0h 0m 27.437s
Error using exportFMU_ME (line 36)
Error(s) encountered while building "SimulinkModelName"
I had successfully exported this same model as FMU – CoSimulation.
exportToFMU2CS(SimulinkModelName)
Why is it possible to export the model under the CoSimulation option and not under the Model Exchange option?
Thank you very much in advance.
Best regards,
Víctor Sánchez Suárez
Norvento Enerxía S.L. Dear Sir or Madam,
I have recently seen that FMU exportation under Model Exchange option has been included in MATLAB R2024b release.
I am trying to export a Simulink model as FMU – Model Exchange using the command:
exportToFMU(SimulinkModelName, ‘FMIVersion’, ‘2.0’, ‘FMUType’, ‘ME’)
However, I get the following error:
The make command returned an error of 2
Build Summary
Top model targets:
Model Build Reason Status
====================================================================================================================
SimulinkModelName Information cache folder or artifacts were missing. Failed to build. For more information, see build log.
0 of 1 models built (0 models already up to date)
Build duration: 0h 0m 27.437s
Error using exportFMU_ME (line 36)
Error(s) encountered while building "SimulinkModelName"
I had successfully exported this same model as FMU – CoSimulation.
exportToFMU2CS(SimulinkModelName)
Why is it possible to export the model under the CoSimulation option and not under the Model Exchange option?
Thank you very much in advance.
Best regards,
Víctor Sánchez Suárez
Norvento Enerxía S.L. fmu, cosimulation, model exchange, fmi MATLAB Answers — New Questions
Accessing Version Details Programmatically, App designer
Hello, In appdesigner there is an option to keep track of the version number for sharing. Is there away to access this programatically. I want to include it in the startup function and display it in the figure name
app.UIFigure.FigureName= ……
ThanksHello, In appdesigner there is an option to keep track of the version number for sharing. Is there away to access this programatically. I want to include it in the startup function and display it in the figure name
app.UIFigure.FigureName= ……
Thanks Hello, In appdesigner there is an option to keep track of the version number for sharing. Is there away to access this programatically. I want to include it in the startup function and display it in the figure name
app.UIFigure.FigureName= ……
Thanks version, startup MATLAB Answers — New Questions
Every time I log in, I get an error message dialog: Error starting MATLAB Connector: One or more services failed to start
I’m running Windows 10, and MATLAB R2023b, although I’ve seen this problem through several prior versions.
Every time I log in, a dialog box pops up with the error message:
Error starting MATLAB Connector: One or more services failed to start
I’ve uninstalled and reinstalled MATLAB Connector multiple times. The Connector itself seems to work when I start MATLAB, but this error message is kind of a pain. What’s going wrong and how can I fix it?I’m running Windows 10, and MATLAB R2023b, although I’ve seen this problem through several prior versions.
Every time I log in, a dialog box pops up with the error message:
Error starting MATLAB Connector: One or more services failed to start
I’ve uninstalled and reinstalled MATLAB Connector multiple times. The Connector itself seems to work when I start MATLAB, but this error message is kind of a pain. What’s going wrong and how can I fix it? I’m running Windows 10, and MATLAB R2023b, although I’ve seen this problem through several prior versions.
Every time I log in, a dialog box pops up with the error message:
Error starting MATLAB Connector: One or more services failed to start
I’ve uninstalled and reinstalled MATLAB Connector multiple times. The Connector itself seems to work when I start MATLAB, but this error message is kind of a pain. What’s going wrong and how can I fix it? connector, error, login MATLAB Answers — New Questions
How does scatteredinterpolant interpolate points on convex hull?
Hello,
i want to know how scatteredinterpolant calculates query points that lie on the convex hull of the sample points.
I need to know this specifically for natural neighbor interpolation. To my understanding points on the convex hull produce unbounded voronoi cells with an infinite area, which means that all weights used for the interpolation should be zero (since the weights are defined as overlapping area devided by the area of the new voronoi cell), which in return means no interpolation is possible.
The interpolation is tested with the following code. The value of qv is returned as 0.5484.
Points=[-1.5 3.2; 1.8 3.2; -3.7 1.5; -1.5 1.3;
0.8 1.2; 3.3 1.5; -4.0 -1.0; -2.3 -0.7;
0 -0.5; 2.0 -1.5; 3.7 -0.8; -3.5 -2.9;
-0.9 -3.9; 2.0 -3.5; 3.5 -2.25];
z=Points(:,2).*sin(Points(:,1)) – Points(:,1).*cos(Points(:,2));
qP=[0.3 3.2];
F = scatteredInterpolant(Points(:,1),Points(:,2),z);
F.Method = ‘natural’;
qv=F(qP);
figure(1)
voronoi(Points(:,1),Points(:,2));
figure(2)
AllPoints=[Points; qP];
voronoi(AllPoints(:,1),AllPoints(:,2));Hello,
i want to know how scatteredinterpolant calculates query points that lie on the convex hull of the sample points.
I need to know this specifically for natural neighbor interpolation. To my understanding points on the convex hull produce unbounded voronoi cells with an infinite area, which means that all weights used for the interpolation should be zero (since the weights are defined as overlapping area devided by the area of the new voronoi cell), which in return means no interpolation is possible.
The interpolation is tested with the following code. The value of qv is returned as 0.5484.
Points=[-1.5 3.2; 1.8 3.2; -3.7 1.5; -1.5 1.3;
0.8 1.2; 3.3 1.5; -4.0 -1.0; -2.3 -0.7;
0 -0.5; 2.0 -1.5; 3.7 -0.8; -3.5 -2.9;
-0.9 -3.9; 2.0 -3.5; 3.5 -2.25];
z=Points(:,2).*sin(Points(:,1)) – Points(:,1).*cos(Points(:,2));
qP=[0.3 3.2];
F = scatteredInterpolant(Points(:,1),Points(:,2),z);
F.Method = ‘natural’;
qv=F(qP);
figure(1)
voronoi(Points(:,1),Points(:,2));
figure(2)
AllPoints=[Points; qP];
voronoi(AllPoints(:,1),AllPoints(:,2)); Hello,
i want to know how scatteredinterpolant calculates query points that lie on the convex hull of the sample points.
I need to know this specifically for natural neighbor interpolation. To my understanding points on the convex hull produce unbounded voronoi cells with an infinite area, which means that all weights used for the interpolation should be zero (since the weights are defined as overlapping area devided by the area of the new voronoi cell), which in return means no interpolation is possible.
The interpolation is tested with the following code. The value of qv is returned as 0.5484.
Points=[-1.5 3.2; 1.8 3.2; -3.7 1.5; -1.5 1.3;
0.8 1.2; 3.3 1.5; -4.0 -1.0; -2.3 -0.7;
0 -0.5; 2.0 -1.5; 3.7 -0.8; -3.5 -2.9;
-0.9 -3.9; 2.0 -3.5; 3.5 -2.25];
z=Points(:,2).*sin(Points(:,1)) – Points(:,1).*cos(Points(:,2));
qP=[0.3 3.2];
F = scatteredInterpolant(Points(:,1),Points(:,2),z);
F.Method = ‘natural’;
qv=F(qP);
figure(1)
voronoi(Points(:,1),Points(:,2));
figure(2)
AllPoints=[Points; qP];
voronoi(AllPoints(:,1),AllPoints(:,2)); interpolation, scatteredinterpolant, convex hull, voronoi, natural neighbor interpolation MATLAB Answers — New Questions
Error using wavedec Expected X to be finite. Error in wavedec (line 34) validateattributes(x,{‘numeric’},{‘vector’,’finite’,’real’},’wavedec’,’X’);
I am using wavedec to discritize my signal using ‘db4’ wavelet.
my X = acceleration vector(9000 x 1)
My X is finite. But I am getting a error that ‘ Error using wavedec Expected X to be finite’
My code :
[a,l] = wavedec(acc,3,’db4′);
approx = appcoef(a,l,’db4′);
[acd1,acd2,acd3] = detcoef(a,l,[1 2 3]);
figure
subplot(4,1,1)
plot(approx)
title(‘Approximation Coefficients’)
subplot(4,1,2)
plot(acd3)
title(‘Level 3 Detail Coefficients’)
subplot(4,1,3)
plot(acd2)
title(‘Level 2 Detail Coefficients’)
subplot(4,1,4)
plot(acd1)
title(‘Level 1 Detail Coefficients’)
please help me. Where I am wrong. I am unable to solve this problem.I am using wavedec to discritize my signal using ‘db4’ wavelet.
my X = acceleration vector(9000 x 1)
My X is finite. But I am getting a error that ‘ Error using wavedec Expected X to be finite’
My code :
[a,l] = wavedec(acc,3,’db4′);
approx = appcoef(a,l,’db4′);
[acd1,acd2,acd3] = detcoef(a,l,[1 2 3]);
figure
subplot(4,1,1)
plot(approx)
title(‘Approximation Coefficients’)
subplot(4,1,2)
plot(acd3)
title(‘Level 3 Detail Coefficients’)
subplot(4,1,3)
plot(acd2)
title(‘Level 2 Detail Coefficients’)
subplot(4,1,4)
plot(acd1)
title(‘Level 1 Detail Coefficients’)
please help me. Where I am wrong. I am unable to solve this problem. I am using wavedec to discritize my signal using ‘db4’ wavelet.
my X = acceleration vector(9000 x 1)
My X is finite. But I am getting a error that ‘ Error using wavedec Expected X to be finite’
My code :
[a,l] = wavedec(acc,3,’db4′);
approx = appcoef(a,l,’db4′);
[acd1,acd2,acd3] = detcoef(a,l,[1 2 3]);
figure
subplot(4,1,1)
plot(approx)
title(‘Approximation Coefficients’)
subplot(4,1,2)
plot(acd3)
title(‘Level 3 Detail Coefficients’)
subplot(4,1,3)
plot(acd2)
title(‘Level 2 Detail Coefficients’)
subplot(4,1,4)
plot(acd1)
title(‘Level 1 Detail Coefficients’)
please help me. Where I am wrong. I am unable to solve this problem. wavelet, discrete wavelet transform MATLAB Answers — New Questions
analysis using wavelet coherence
i want to perfom rossby wave detection using the wavelet coherence, but when i running the code there is always an error that says "error in wt.m time must be constant". when i change the year in the first clumn to numbers, the code runs. but when I include the first column as the years, the error massage appears. My data consists of 20 years,is there something wrong with my data?i want to perfom rossby wave detection using the wavelet coherence, but when i running the code there is always an error that says "error in wt.m time must be constant". when i change the year in the first clumn to numbers, the code runs. but when I include the first column as the years, the error massage appears. My data consists of 20 years,is there something wrong with my data? i want to perfom rossby wave detection using the wavelet coherence, but when i running the code there is always an error that says "error in wt.m time must be constant". when i change the year in the first clumn to numbers, the code runs. but when I include the first column as the years, the error massage appears. My data consists of 20 years,is there something wrong with my data? wavelet, digital signal processing MATLAB Answers — New Questions
why the Files AMSimulink.mdl and Aspentech-Matlab not available
C:Program FilesMATLABbin…..? after Matlab 2024a installationC:Program FilesMATLABbin…..? after Matlab 2024a installation C:Program FilesMATLABbin…..? after Matlab 2024a installation amsimulink.mdl MATLAB Answers — New Questions
what is this type “sfix16_Sp1_Bn25”
What is
"sfix16_Sp1_Bn25" this type mean for?What is
"sfix16_Sp1_Bn25" this type mean for? What is
"sfix16_Sp1_Bn25" this type mean for? type MATLAB Answers — New Questions
muti input cnn in matalb how to do that and how to feed the data in the model?
I want to train a muti input cnn in matalb how to do that and how to feed the data in the model?
like in python we do this:
history=final_model.fit(x=[X_insp_tr, X_exp_tr], y=y_tr,
epochs=100, batch_size=32,
validation_data=([X_insp_val, X_exp_val], y_val))I want to train a muti input cnn in matalb how to do that and how to feed the data in the model?
like in python we do this:
history=final_model.fit(x=[X_insp_tr, X_exp_tr], y=y_tr,
epochs=100, batch_size=32,
validation_data=([X_insp_val, X_exp_val], y_val)) I want to train a muti input cnn in matalb how to do that and how to feed the data in the model?
like in python we do this:
history=final_model.fit(x=[X_insp_tr, X_exp_tr], y=y_tr,
epochs=100, batch_size=32,
validation_data=([X_insp_val, X_exp_val], y_val)) deep learning, cnn, multi-input-cnn, multi-scale cnn MATLAB Answers — New Questions
Simscape Isothermal Fluids – Pressure sensor
This is a system of a gear pump connected to a load. The angular velocity is to be maintained constant. The Pressure sensor reads only 1.12bar, it does not reflect the pressure due to the conneted load. Am I missing something here?. There is a load of about 300kgs which needs to rotated, so there should be pressure built up due to the load.This is a system of a gear pump connected to a load. The angular velocity is to be maintained constant. The Pressure sensor reads only 1.12bar, it does not reflect the pressure due to the conneted load. Am I missing something here?. There is a load of about 300kgs which needs to rotated, so there should be pressure built up due to the load. This is a system of a gear pump connected to a load. The angular velocity is to be maintained constant. The Pressure sensor reads only 1.12bar, it does not reflect the pressure due to the conneted load. Am I missing something here?. There is a load of about 300kgs which needs to rotated, so there should be pressure built up due to the load. pressure sensor il MATLAB Answers — New Questions
Can I download installation files for the Embedded Coder® Support Package for AUTOSAR Standard?
I would like to download the Embedded Coder® Support Package for AUTOSAR Standard now when I have internet access but install it later when I do not have internet access.I would like to download the Embedded Coder® Support Package for AUTOSAR Standard now when I have internet access but install it later when I do not have internet access. I would like to download the Embedded Coder® Support Package for AUTOSAR Standard now when I have internet access but install it later when I do not have internet access. autosar, software components, runnable, automotive, control design MATLAB Answers — New Questions