Category: Matlab
Category Archives: Matlab
Obtaining posterior covariance of GPR using fitrgp and predictExactWithCov
Hello, thank you for reading this question. I have a question about using matlab’s (maybe undocumented) function predictExactWithCov.
I have found in this forum that if I have a RegressionGP gprmdl, set of test points xTest, then by using
[postMeanGPR,postCovGPR,confInt] = predictExactWithCov(gprmdl.Impl,xTest,0.05);
I can obtain an posterior mean of gprmdl at xTest (postMeanGPR), posterior covariance matrix at xTest (postCovGPR), and 95% confidence interval based on covariance matrix (confInt).
On the other hand, I can calculate posterior mean and variance using
(*)
where zero prior is assumed, is a kernel, and so on.
However, using the kernel information from gprmdl like
sig_f = gprmdl.KernelInformation.KernelParameters(12);
sig_l = gprmdl.KernelInformation.KernelParameters(1:11)’;
lambda = gprmdl.Sigma;
and calculating posterior mean and covariance using equation (*), I can obtain a same mean as postMeanGPR but posterior variance was quite different with postCovGPR’s diagonal elements.
Can anyone explain why does such a discrepency occur?
Thanks.
PS: the overall code is attached below
clear;
clc;
wineTable = readtable(‘winequality-red.csv’); % wine data from cortez et al 2009., file attached
% 1st-11th columns are inputs and 12th column is output
wineData = table2array(wineTable);
len_tot = length(wineData);
len_train = 1000;
len_test = len_tot – len_train;
DataTrain = zeros(len_train,12);
DataTest = zeros(len_test,12);
NN = 1;
rng(NN);
%% STEP 1. Load data and separate it into training and test sets
p = sort(randperm(len_tot,len_test));
jj = 1; kk = 1;
for ii = 1:len_tot
if ismember(ii,p’,’rows’)
DataTest(jj,:) = wineData(ii,:);
jj = jj + 1;
else
DataTrain(kk,:) = wineData(ii,:);
kk = kk + 1;
end
end
%% STEP 2. Calculate GP posterior mean and covariance using predictExactWithCov
xTrain = DataTrain(:,1:11);
yTrain = DataTrain(:,12);
xTest = DataTest(:,1:11);
yTest = DataTest(:,12);
gprmdl = fitrgp(xTrain,yTrain,’KernelFunction’,’ardsquaredexponential’,’BasisFunction’,’none’);
[postMeanGPR,postCovGPR,confInt] = predictExactWithCov(gprmdl.Impl,xTest,0.05);
%% STEP 3. Calculate GP posterior mean and variance using equation (*)
Gram = Kmat(xTrain,sig_f,sig_l);
sig_f = gprmdl.KernelInformation.KernelParameters(12);
sig_l = gprmdl.KernelInformation.KernelParameters(1:11)’;
lambda = gprmdl.Sigma;
KinvY = (Gram + lambda^2*eye(len_train))yTrain;
postMeanGPR2 = zeros(len_test,1);
postVarGPR2 = postMeanGPR2;
for ii = 1:len_test
postMeanGPR2(ii) = kCol(xTest(ii,:),xTrain,sig_f,sig_l)’*KinvY;
postVarGPR2(ii) = SE(xTest(ii,:),xTest(ii,:),sig_f,sig_l) – kCol(xTest(ii,:),xTrain,sig_f,sig_l)’*((Gram + lambda^2*eye(len_train))kCol(xTest(ii,:),xTrain,sig_f,sig_l));
end
function val = SE(x1, x2, sig_f, sig_l)
% x1, x2 in R^d, row vectors
% hyperparameter sig_l: length scale, length(sig_l) = d, sig_f > 0
Lambda = diag(sig_l);
val = sig_f^2 * exp(-0.5*( (x1 – x2) /Lambda^2 * (x1 – x2)’ ) );
end
function k = kCol(xTest, xTrain, sig_f, sig_l)
% xTest: Test point, row vector
% xTrain: Training points, each row corresponds to one training point
N = length(xTrain);
k = zeros(N,1);
for ii = 1:N
k(ii) = SE(xTest, xTrain(ii,:), sig_f, sig_l);
end
end
function K = Kmat(X, sig_f, sig_l)
% each row of X corresponds to one data point of Gram matrix K
n = length(X);
K = zeros(n,n);
for ii = 1:n
for jj = 1:n
K(ii,jj) = SE(X(ii,:),X(jj,:), sig_f, sig_l);
end
end
endHello, thank you for reading this question. I have a question about using matlab’s (maybe undocumented) function predictExactWithCov.
I have found in this forum that if I have a RegressionGP gprmdl, set of test points xTest, then by using
[postMeanGPR,postCovGPR,confInt] = predictExactWithCov(gprmdl.Impl,xTest,0.05);
I can obtain an posterior mean of gprmdl at xTest (postMeanGPR), posterior covariance matrix at xTest (postCovGPR), and 95% confidence interval based on covariance matrix (confInt).
On the other hand, I can calculate posterior mean and variance using
(*)
where zero prior is assumed, is a kernel, and so on.
However, using the kernel information from gprmdl like
sig_f = gprmdl.KernelInformation.KernelParameters(12);
sig_l = gprmdl.KernelInformation.KernelParameters(1:11)’;
lambda = gprmdl.Sigma;
and calculating posterior mean and covariance using equation (*), I can obtain a same mean as postMeanGPR but posterior variance was quite different with postCovGPR’s diagonal elements.
Can anyone explain why does such a discrepency occur?
Thanks.
PS: the overall code is attached below
clear;
clc;
wineTable = readtable(‘winequality-red.csv’); % wine data from cortez et al 2009., file attached
% 1st-11th columns are inputs and 12th column is output
wineData = table2array(wineTable);
len_tot = length(wineData);
len_train = 1000;
len_test = len_tot – len_train;
DataTrain = zeros(len_train,12);
DataTest = zeros(len_test,12);
NN = 1;
rng(NN);
%% STEP 1. Load data and separate it into training and test sets
p = sort(randperm(len_tot,len_test));
jj = 1; kk = 1;
for ii = 1:len_tot
if ismember(ii,p’,’rows’)
DataTest(jj,:) = wineData(ii,:);
jj = jj + 1;
else
DataTrain(kk,:) = wineData(ii,:);
kk = kk + 1;
end
end
%% STEP 2. Calculate GP posterior mean and covariance using predictExactWithCov
xTrain = DataTrain(:,1:11);
yTrain = DataTrain(:,12);
xTest = DataTest(:,1:11);
yTest = DataTest(:,12);
gprmdl = fitrgp(xTrain,yTrain,’KernelFunction’,’ardsquaredexponential’,’BasisFunction’,’none’);
[postMeanGPR,postCovGPR,confInt] = predictExactWithCov(gprmdl.Impl,xTest,0.05);
%% STEP 3. Calculate GP posterior mean and variance using equation (*)
Gram = Kmat(xTrain,sig_f,sig_l);
sig_f = gprmdl.KernelInformation.KernelParameters(12);
sig_l = gprmdl.KernelInformation.KernelParameters(1:11)’;
lambda = gprmdl.Sigma;
KinvY = (Gram + lambda^2*eye(len_train))yTrain;
postMeanGPR2 = zeros(len_test,1);
postVarGPR2 = postMeanGPR2;
for ii = 1:len_test
postMeanGPR2(ii) = kCol(xTest(ii,:),xTrain,sig_f,sig_l)’*KinvY;
postVarGPR2(ii) = SE(xTest(ii,:),xTest(ii,:),sig_f,sig_l) – kCol(xTest(ii,:),xTrain,sig_f,sig_l)’*((Gram + lambda^2*eye(len_train))kCol(xTest(ii,:),xTrain,sig_f,sig_l));
end
function val = SE(x1, x2, sig_f, sig_l)
% x1, x2 in R^d, row vectors
% hyperparameter sig_l: length scale, length(sig_l) = d, sig_f > 0
Lambda = diag(sig_l);
val = sig_f^2 * exp(-0.5*( (x1 – x2) /Lambda^2 * (x1 – x2)’ ) );
end
function k = kCol(xTest, xTrain, sig_f, sig_l)
% xTest: Test point, row vector
% xTrain: Training points, each row corresponds to one training point
N = length(xTrain);
k = zeros(N,1);
for ii = 1:N
k(ii) = SE(xTest, xTrain(ii,:), sig_f, sig_l);
end
end
function K = Kmat(X, sig_f, sig_l)
% each row of X corresponds to one data point of Gram matrix K
n = length(X);
K = zeros(n,n);
for ii = 1:n
for jj = 1:n
K(ii,jj) = SE(X(ii,:),X(jj,:), sig_f, sig_l);
end
end
end Hello, thank you for reading this question. I have a question about using matlab’s (maybe undocumented) function predictExactWithCov.
I have found in this forum that if I have a RegressionGP gprmdl, set of test points xTest, then by using
[postMeanGPR,postCovGPR,confInt] = predictExactWithCov(gprmdl.Impl,xTest,0.05);
I can obtain an posterior mean of gprmdl at xTest (postMeanGPR), posterior covariance matrix at xTest (postCovGPR), and 95% confidence interval based on covariance matrix (confInt).
On the other hand, I can calculate posterior mean and variance using
(*)
where zero prior is assumed, is a kernel, and so on.
However, using the kernel information from gprmdl like
sig_f = gprmdl.KernelInformation.KernelParameters(12);
sig_l = gprmdl.KernelInformation.KernelParameters(1:11)’;
lambda = gprmdl.Sigma;
and calculating posterior mean and covariance using equation (*), I can obtain a same mean as postMeanGPR but posterior variance was quite different with postCovGPR’s diagonal elements.
Can anyone explain why does such a discrepency occur?
Thanks.
PS: the overall code is attached below
clear;
clc;
wineTable = readtable(‘winequality-red.csv’); % wine data from cortez et al 2009., file attached
% 1st-11th columns are inputs and 12th column is output
wineData = table2array(wineTable);
len_tot = length(wineData);
len_train = 1000;
len_test = len_tot – len_train;
DataTrain = zeros(len_train,12);
DataTest = zeros(len_test,12);
NN = 1;
rng(NN);
%% STEP 1. Load data and separate it into training and test sets
p = sort(randperm(len_tot,len_test));
jj = 1; kk = 1;
for ii = 1:len_tot
if ismember(ii,p’,’rows’)
DataTest(jj,:) = wineData(ii,:);
jj = jj + 1;
else
DataTrain(kk,:) = wineData(ii,:);
kk = kk + 1;
end
end
%% STEP 2. Calculate GP posterior mean and covariance using predictExactWithCov
xTrain = DataTrain(:,1:11);
yTrain = DataTrain(:,12);
xTest = DataTest(:,1:11);
yTest = DataTest(:,12);
gprmdl = fitrgp(xTrain,yTrain,’KernelFunction’,’ardsquaredexponential’,’BasisFunction’,’none’);
[postMeanGPR,postCovGPR,confInt] = predictExactWithCov(gprmdl.Impl,xTest,0.05);
%% STEP 3. Calculate GP posterior mean and variance using equation (*)
Gram = Kmat(xTrain,sig_f,sig_l);
sig_f = gprmdl.KernelInformation.KernelParameters(12);
sig_l = gprmdl.KernelInformation.KernelParameters(1:11)’;
lambda = gprmdl.Sigma;
KinvY = (Gram + lambda^2*eye(len_train))yTrain;
postMeanGPR2 = zeros(len_test,1);
postVarGPR2 = postMeanGPR2;
for ii = 1:len_test
postMeanGPR2(ii) = kCol(xTest(ii,:),xTrain,sig_f,sig_l)’*KinvY;
postVarGPR2(ii) = SE(xTest(ii,:),xTest(ii,:),sig_f,sig_l) – kCol(xTest(ii,:),xTrain,sig_f,sig_l)’*((Gram + lambda^2*eye(len_train))kCol(xTest(ii,:),xTrain,sig_f,sig_l));
end
function val = SE(x1, x2, sig_f, sig_l)
% x1, x2 in R^d, row vectors
% hyperparameter sig_l: length scale, length(sig_l) = d, sig_f > 0
Lambda = diag(sig_l);
val = sig_f^2 * exp(-0.5*( (x1 – x2) /Lambda^2 * (x1 – x2)’ ) );
end
function k = kCol(xTest, xTrain, sig_f, sig_l)
% xTest: Test point, row vector
% xTrain: Training points, each row corresponds to one training point
N = length(xTrain);
k = zeros(N,1);
for ii = 1:N
k(ii) = SE(xTest, xTrain(ii,:), sig_f, sig_l);
end
end
function K = Kmat(X, sig_f, sig_l)
% each row of X corresponds to one data point of Gram matrix K
n = length(X);
K = zeros(n,n);
for ii = 1:n
for jj = 1:n
K(ii,jj) = SE(X(ii,:),X(jj,:), sig_f, sig_l);
end
end
end matlab, gaussian process regression, posterior covariance matrix MATLAB Answers — New Questions
Correct fetchNext index after clearing FevalFuture object
I am using parfeval to run code asynchronously on workers. The running time varies a lot between workers depending on some parameters that in the following code I represent with ‘m’.
When I collect the results with fetchNext, I then process them with idx, in particular retrieving m(idx). At the same time, I need to clear the last retrieved FevalFuture object to save memory.
In Parfeval – Memory consumption piling up – Clear output data? it is suggest to simply assign [ ] to the FevalFuture object. However, it seems to me that doing this mix up the indices idx of the objects, which I need to further process the data. See for instance this mve
N = 10;
m = 1:10;
for idx = N:-1:1
f(idx) = parfeval(@(m,N) m*rand(N), 1, m(idx), N);
end
total = 0;
for idx = 1:N
[idx, data] = fetchNext(f);
idx
f(idx) = []; % This line here
% process data with idx, m(idx) ..
end
If you comment the line indicated the code will work fine, but if I clear f(idx) the just-used idx could be reused and I would process the data with the wrong m(idx).
How is it possible to get the correct index idx with which f(idx) was called in the fist loop?
Thanks in advantageI am using parfeval to run code asynchronously on workers. The running time varies a lot between workers depending on some parameters that in the following code I represent with ‘m’.
When I collect the results with fetchNext, I then process them with idx, in particular retrieving m(idx). At the same time, I need to clear the last retrieved FevalFuture object to save memory.
In Parfeval – Memory consumption piling up – Clear output data? it is suggest to simply assign [ ] to the FevalFuture object. However, it seems to me that doing this mix up the indices idx of the objects, which I need to further process the data. See for instance this mve
N = 10;
m = 1:10;
for idx = N:-1:1
f(idx) = parfeval(@(m,N) m*rand(N), 1, m(idx), N);
end
total = 0;
for idx = 1:N
[idx, data] = fetchNext(f);
idx
f(idx) = []; % This line here
% process data with idx, m(idx) ..
end
If you comment the line indicated the code will work fine, but if I clear f(idx) the just-used idx could be reused and I would process the data with the wrong m(idx).
How is it possible to get the correct index idx with which f(idx) was called in the fist loop?
Thanks in advantage I am using parfeval to run code asynchronously on workers. The running time varies a lot between workers depending on some parameters that in the following code I represent with ‘m’.
When I collect the results with fetchNext, I then process them with idx, in particular retrieving m(idx). At the same time, I need to clear the last retrieved FevalFuture object to save memory.
In Parfeval – Memory consumption piling up – Clear output data? it is suggest to simply assign [ ] to the FevalFuture object. However, it seems to me that doing this mix up the indices idx of the objects, which I need to further process the data. See for instance this mve
N = 10;
m = 1:10;
for idx = N:-1:1
f(idx) = parfeval(@(m,N) m*rand(N), 1, m(idx), N);
end
total = 0;
for idx = 1:N
[idx, data] = fetchNext(f);
idx
f(idx) = []; % This line here
% process data with idx, m(idx) ..
end
If you comment the line indicated the code will work fine, but if I clear f(idx) the just-used idx could be reused and I would process the data with the wrong m(idx).
How is it possible to get the correct index idx with which f(idx) was called in the fist loop?
Thanks in advantage parfeval, fetchnext MATLAB Answers — New Questions
PID controller tuning for time-varying input
Hi all, I am trying to tune a PID controller using the Control System Tuner. In particular, the main aim of this controller would be to follow a time-varying signal (a ramp, for example) with zero steady-state error. I would like to know if, using the Control System Tuner Requirements, is possible to accomplish this task. If not, which are the alternative solutions? Thank you!Hi all, I am trying to tune a PID controller using the Control System Tuner. In particular, the main aim of this controller would be to follow a time-varying signal (a ramp, for example) with zero steady-state error. I would like to know if, using the Control System Tuner Requirements, is possible to accomplish this task. If not, which are the alternative solutions? Thank you! Hi all, I am trying to tune a PID controller using the Control System Tuner. In particular, the main aim of this controller would be to follow a time-varying signal (a ramp, for example) with zero steady-state error. I would like to know if, using the Control System Tuner Requirements, is possible to accomplish this task. If not, which are the alternative solutions? Thank you! pid, control, ramp, simulink, matlab MATLAB Answers — New Questions
Deep Neural Network – Validation accuracy unchanged
I would like to ask you for a help or advice. I try to construct and learn deep learning neural network (DLNN) in area of stock market in Matlab. My goal is to forecast next day price movement based on five time-series sequences (open, close, high, low price and volume). According to my best knowledge the best type of DLNN for such problem is using Long short-term memory (LSTM) layer or Bidirectional long short-term memory (BiLSTM) for recurrent neural network (RNN). I create the DLNN with following layers structure, train, validation and test data in ratios of 80%:10%:10%.
Input dataset consist of 365 days price movement observations (from 2014 until now) charecterized by five time-series sequences (open, close, high, low price and volume) and associated label (UP or DOWN) corresponding to the close price in the next day. In this way (80%:10%:10%) it is possible to create 1721 train, 215 validation and 216 test data groups each in 365×5 dimmensions. I try to used trainnet function with adam solver. However to my surprise, I always get the exactly the same value of Validation accuracy result about 50 what I interpret to myself as some king of systematic error. I get (see picture)
1. oscillating around 50 (if InitialLearnRate is high)
2. stay near up or down around 50 (if InitialLearnRate is low)
From my point of view I suppose that I do someting wrong but really dont know where to look for the error. For this reason, I appeal to you, more experienced community for a help. The code is below and I also attach the source code together with saved workspace (consisting of dln associated DLNN generated from deepNetworkDesigner), if anyone has interest. Please here is the google drive link (external link because size is greater than allowed 5MB): DLN – market.zip
Thank you for any advice.
CODE:
%% Start Script
load(‘./Workspace/dln.mat’);
filename = ‘./Training data/HistoricalData_1715268339888.csv’;
seriesLength =365;
%% Data import, format, create datasets
dataImport = readmatrix(filename); % data import
dataFlip = flipud(dataImport); % data flipping, older first
samplesSize = size(dataFlip,1)-seriesLength+1; % size (amount) of input samples
% create dataset:
%*************************
data = cell(samplesSize,1);
for i=1:samplesSize
data{i,1} = dataFlip(i:(seriesLength-1+i),2:end); % 2:end), end change to 2
end
% create labels
%*************************
priceMovement = cell(samplesSize-1,1);
for j=1:(samplesSize-1)
if data{j}(end,1)<data{j+1}(end,1)
priceMovement{j} = ‘UP’;
else
priceMovement{j} = ‘DOWN’;
end
end
data = data(1:end-1); % last day has no any forecast, must be removed
labels = categorical(priceMovement); % two categories of price movement forecast: 1.up 2.down
classNames = categories(labels);
paramsCount = size(data{1},2);
%% Show datasets (first four dataset group)
figure
tiledlayout(2,2)
for i = 1:4
nexttile
stackedplot(data{i},DisplayLabels="Parameter "+string(1:paramsCount))
xlabel("Order [day]")
title("Class: " + string(labels(i)))
end
%% Partition the data into a training validation and test sets
numObservations = numel(data);
[idxTrain,idxValidation,idxTest] = trainingPartitions(numObservations,[0.8 0.1 0.1]);
% separate Train Data
%*************************
XTrain = data(idxTrain);
TTrain = labels(idxTrain);
% separate Validation Data
%*************************
XValidation = data(idxValidation);
TValidation = labels(idxValidation);
% separate Test Data
%*************************
XTest = data(idxTest);
TTest = labels(idxTest);
%% Build Deep Learning Neural Network by ‘deepNetworkDesigner’ according to example in URL
% deepNetworkDesigner;
%% Specify the training options.
options = trainingOptions("adam", … % adam
MaxEpochs=2000,…
InitialLearnRate=0.0005, … % InitialLearnRate=0.0005, ..
GradientThreshold=5, … % GradientThreshold=10, …
Shuffle = "every-epoch", … % Shuffle = "every-epoch", …
ValidationData={XValidation,TValidation},…
Plots="training-progress", …
OutputNetwork= ‘best-validation’,…
Acceleration= "auto",…
Verbose=false,…
ValidationFrequency=5,…
Metrics=("accuracy"));
%% Train Neural Network
[netNN,netNNinfo] = trainnet(XTrain,TTrain,dln,"binary-crossentropy",options); % this clasification issue belongs to binary problem, therefore used "binary-crossentropy" instead of "crossentropy"
%% Show Trained Neural Network
show(netNNinfo);
%% Test Neural Network
netScores = minibatchpredict(netNN,XTest); % insert test samples into trained network
YTest = scores2label(netScores,classNames); % conversion scores to labels
netAcc = mean(YTest == TTest)*100; % in [%], classification accuracy calculation
%% Visualize the predictions in a confusion chart
figure
confusionchart(TTest,YTest)
showI would like to ask you for a help or advice. I try to construct and learn deep learning neural network (DLNN) in area of stock market in Matlab. My goal is to forecast next day price movement based on five time-series sequences (open, close, high, low price and volume). According to my best knowledge the best type of DLNN for such problem is using Long short-term memory (LSTM) layer or Bidirectional long short-term memory (BiLSTM) for recurrent neural network (RNN). I create the DLNN with following layers structure, train, validation and test data in ratios of 80%:10%:10%.
Input dataset consist of 365 days price movement observations (from 2014 until now) charecterized by five time-series sequences (open, close, high, low price and volume) and associated label (UP or DOWN) corresponding to the close price in the next day. In this way (80%:10%:10%) it is possible to create 1721 train, 215 validation and 216 test data groups each in 365×5 dimmensions. I try to used trainnet function with adam solver. However to my surprise, I always get the exactly the same value of Validation accuracy result about 50 what I interpret to myself as some king of systematic error. I get (see picture)
1. oscillating around 50 (if InitialLearnRate is high)
2. stay near up or down around 50 (if InitialLearnRate is low)
From my point of view I suppose that I do someting wrong but really dont know where to look for the error. For this reason, I appeal to you, more experienced community for a help. The code is below and I also attach the source code together with saved workspace (consisting of dln associated DLNN generated from deepNetworkDesigner), if anyone has interest. Please here is the google drive link (external link because size is greater than allowed 5MB): DLN – market.zip
Thank you for any advice.
CODE:
%% Start Script
load(‘./Workspace/dln.mat’);
filename = ‘./Training data/HistoricalData_1715268339888.csv’;
seriesLength =365;
%% Data import, format, create datasets
dataImport = readmatrix(filename); % data import
dataFlip = flipud(dataImport); % data flipping, older first
samplesSize = size(dataFlip,1)-seriesLength+1; % size (amount) of input samples
% create dataset:
%*************************
data = cell(samplesSize,1);
for i=1:samplesSize
data{i,1} = dataFlip(i:(seriesLength-1+i),2:end); % 2:end), end change to 2
end
% create labels
%*************************
priceMovement = cell(samplesSize-1,1);
for j=1:(samplesSize-1)
if data{j}(end,1)<data{j+1}(end,1)
priceMovement{j} = ‘UP’;
else
priceMovement{j} = ‘DOWN’;
end
end
data = data(1:end-1); % last day has no any forecast, must be removed
labels = categorical(priceMovement); % two categories of price movement forecast: 1.up 2.down
classNames = categories(labels);
paramsCount = size(data{1},2);
%% Show datasets (first four dataset group)
figure
tiledlayout(2,2)
for i = 1:4
nexttile
stackedplot(data{i},DisplayLabels="Parameter "+string(1:paramsCount))
xlabel("Order [day]")
title("Class: " + string(labels(i)))
end
%% Partition the data into a training validation and test sets
numObservations = numel(data);
[idxTrain,idxValidation,idxTest] = trainingPartitions(numObservations,[0.8 0.1 0.1]);
% separate Train Data
%*************************
XTrain = data(idxTrain);
TTrain = labels(idxTrain);
% separate Validation Data
%*************************
XValidation = data(idxValidation);
TValidation = labels(idxValidation);
% separate Test Data
%*************************
XTest = data(idxTest);
TTest = labels(idxTest);
%% Build Deep Learning Neural Network by ‘deepNetworkDesigner’ according to example in URL
% deepNetworkDesigner;
%% Specify the training options.
options = trainingOptions("adam", … % adam
MaxEpochs=2000,…
InitialLearnRate=0.0005, … % InitialLearnRate=0.0005, ..
GradientThreshold=5, … % GradientThreshold=10, …
Shuffle = "every-epoch", … % Shuffle = "every-epoch", …
ValidationData={XValidation,TValidation},…
Plots="training-progress", …
OutputNetwork= ‘best-validation’,…
Acceleration= "auto",…
Verbose=false,…
ValidationFrequency=5,…
Metrics=("accuracy"));
%% Train Neural Network
[netNN,netNNinfo] = trainnet(XTrain,TTrain,dln,"binary-crossentropy",options); % this clasification issue belongs to binary problem, therefore used "binary-crossentropy" instead of "crossentropy"
%% Show Trained Neural Network
show(netNNinfo);
%% Test Neural Network
netScores = minibatchpredict(netNN,XTest); % insert test samples into trained network
YTest = scores2label(netScores,classNames); % conversion scores to labels
netAcc = mean(YTest == TTest)*100; % in [%], classification accuracy calculation
%% Visualize the predictions in a confusion chart
figure
confusionchart(TTest,YTest)
show I would like to ask you for a help or advice. I try to construct and learn deep learning neural network (DLNN) in area of stock market in Matlab. My goal is to forecast next day price movement based on five time-series sequences (open, close, high, low price and volume). According to my best knowledge the best type of DLNN for such problem is using Long short-term memory (LSTM) layer or Bidirectional long short-term memory (BiLSTM) for recurrent neural network (RNN). I create the DLNN with following layers structure, train, validation and test data in ratios of 80%:10%:10%.
Input dataset consist of 365 days price movement observations (from 2014 until now) charecterized by five time-series sequences (open, close, high, low price and volume) and associated label (UP or DOWN) corresponding to the close price in the next day. In this way (80%:10%:10%) it is possible to create 1721 train, 215 validation and 216 test data groups each in 365×5 dimmensions. I try to used trainnet function with adam solver. However to my surprise, I always get the exactly the same value of Validation accuracy result about 50 what I interpret to myself as some king of systematic error. I get (see picture)
1. oscillating around 50 (if InitialLearnRate is high)
2. stay near up or down around 50 (if InitialLearnRate is low)
From my point of view I suppose that I do someting wrong but really dont know where to look for the error. For this reason, I appeal to you, more experienced community for a help. The code is below and I also attach the source code together with saved workspace (consisting of dln associated DLNN generated from deepNetworkDesigner), if anyone has interest. Please here is the google drive link (external link because size is greater than allowed 5MB): DLN – market.zip
Thank you for any advice.
CODE:
%% Start Script
load(‘./Workspace/dln.mat’);
filename = ‘./Training data/HistoricalData_1715268339888.csv’;
seriesLength =365;
%% Data import, format, create datasets
dataImport = readmatrix(filename); % data import
dataFlip = flipud(dataImport); % data flipping, older first
samplesSize = size(dataFlip,1)-seriesLength+1; % size (amount) of input samples
% create dataset:
%*************************
data = cell(samplesSize,1);
for i=1:samplesSize
data{i,1} = dataFlip(i:(seriesLength-1+i),2:end); % 2:end), end change to 2
end
% create labels
%*************************
priceMovement = cell(samplesSize-1,1);
for j=1:(samplesSize-1)
if data{j}(end,1)<data{j+1}(end,1)
priceMovement{j} = ‘UP’;
else
priceMovement{j} = ‘DOWN’;
end
end
data = data(1:end-1); % last day has no any forecast, must be removed
labels = categorical(priceMovement); % two categories of price movement forecast: 1.up 2.down
classNames = categories(labels);
paramsCount = size(data{1},2);
%% Show datasets (first four dataset group)
figure
tiledlayout(2,2)
for i = 1:4
nexttile
stackedplot(data{i},DisplayLabels="Parameter "+string(1:paramsCount))
xlabel("Order [day]")
title("Class: " + string(labels(i)))
end
%% Partition the data into a training validation and test sets
numObservations = numel(data);
[idxTrain,idxValidation,idxTest] = trainingPartitions(numObservations,[0.8 0.1 0.1]);
% separate Train Data
%*************************
XTrain = data(idxTrain);
TTrain = labels(idxTrain);
% separate Validation Data
%*************************
XValidation = data(idxValidation);
TValidation = labels(idxValidation);
% separate Test Data
%*************************
XTest = data(idxTest);
TTest = labels(idxTest);
%% Build Deep Learning Neural Network by ‘deepNetworkDesigner’ according to example in URL
% deepNetworkDesigner;
%% Specify the training options.
options = trainingOptions("adam", … % adam
MaxEpochs=2000,…
InitialLearnRate=0.0005, … % InitialLearnRate=0.0005, ..
GradientThreshold=5, … % GradientThreshold=10, …
Shuffle = "every-epoch", … % Shuffle = "every-epoch", …
ValidationData={XValidation,TValidation},…
Plots="training-progress", …
OutputNetwork= ‘best-validation’,…
Acceleration= "auto",…
Verbose=false,…
ValidationFrequency=5,…
Metrics=("accuracy"));
%% Train Neural Network
[netNN,netNNinfo] = trainnet(XTrain,TTrain,dln,"binary-crossentropy",options); % this clasification issue belongs to binary problem, therefore used "binary-crossentropy" instead of "crossentropy"
%% Show Trained Neural Network
show(netNNinfo);
%% Test Neural Network
netScores = minibatchpredict(netNN,XTest); % insert test samples into trained network
YTest = scores2label(netScores,classNames); % conversion scores to labels
netAcc = mean(YTest == TTest)*100; % in [%], classification accuracy calculation
%% Visualize the predictions in a confusion chart
figure
confusionchart(TTest,YTest)
show deep learning, validation accuracy, lstm, bilstm MATLAB Answers — New Questions
imagesc graph axis setting probelm in Matlab Appdesigner
…
%% Loop start
numRows = length(shiftedDistance);
numCols = app.MaxMeasCountEditField.Value;
if isempty(app.dataMatrix)
app.dataMatrix = nan(numRows, numCols);
end
app.stop_loop = false;
if isempty(app.Ascan_cnt)
app.Ascan_cnt = 0;
end
while app.Ascan_cnt <= app.MaxMeasCountEditField.Value && app.stop_loop == false
% Add new data on the dataMatrix
if app.Ascan_cnt > numCols
% If I need to add cols
app.dataMatrix = [app.dataMatrix, nan(numRows, 1)];
numCols = numCols + 1;
end
app.dataMatrix(:, app.Ascan_cnt + 1) = newData;
% NaN to Zero
app.dataMatrix(isnan(app.dataMatrix)) = 0;
% image update
imagesc(app.UIAxes3_1, [1 app.Ascan_cnt], [min(shiftedDistance) max(shiftedDistance)], app.dataMatrix);
% xlim set
if app.Ascan_cnt > 50
xlim(app.UIAxes3_1, [app.Ascan_cnt – 49 app.Ascan_cnt]);
else
xlim(app.UIAxes3_1, [1 50]);
end
% ylim set
ylim(app.UIAxes3_1, [min(shiftedDistance) max(shiftedDistance)]);
colormap(app.UIAxes3_1, ‘gray’);
axis(app.UIAxes3_1, ‘tight’);
set(app.UIAxes3_1, ‘YDir’, ‘reverse’);
clim(app.UIAxes3_1, [0, app.ImageScalingEditField.Value]);
…
My code is like those.
I have a problem on setting the X axis in the Matlab appdesigner imagesc.
I want to add measured datas one by one on the defined Matrix.
And, I want the initial X axis with 50 components, and moving through when components are over 50s.
But, the datas add along arbitrary value even not integer.
what is my problem?…
%% Loop start
numRows = length(shiftedDistance);
numCols = app.MaxMeasCountEditField.Value;
if isempty(app.dataMatrix)
app.dataMatrix = nan(numRows, numCols);
end
app.stop_loop = false;
if isempty(app.Ascan_cnt)
app.Ascan_cnt = 0;
end
while app.Ascan_cnt <= app.MaxMeasCountEditField.Value && app.stop_loop == false
% Add new data on the dataMatrix
if app.Ascan_cnt > numCols
% If I need to add cols
app.dataMatrix = [app.dataMatrix, nan(numRows, 1)];
numCols = numCols + 1;
end
app.dataMatrix(:, app.Ascan_cnt + 1) = newData;
% NaN to Zero
app.dataMatrix(isnan(app.dataMatrix)) = 0;
% image update
imagesc(app.UIAxes3_1, [1 app.Ascan_cnt], [min(shiftedDistance) max(shiftedDistance)], app.dataMatrix);
% xlim set
if app.Ascan_cnt > 50
xlim(app.UIAxes3_1, [app.Ascan_cnt – 49 app.Ascan_cnt]);
else
xlim(app.UIAxes3_1, [1 50]);
end
% ylim set
ylim(app.UIAxes3_1, [min(shiftedDistance) max(shiftedDistance)]);
colormap(app.UIAxes3_1, ‘gray’);
axis(app.UIAxes3_1, ‘tight’);
set(app.UIAxes3_1, ‘YDir’, ‘reverse’);
clim(app.UIAxes3_1, [0, app.ImageScalingEditField.Value]);
…
My code is like those.
I have a problem on setting the X axis in the Matlab appdesigner imagesc.
I want to add measured datas one by one on the defined Matrix.
And, I want the initial X axis with 50 components, and moving through when components are over 50s.
But, the datas add along arbitrary value even not integer.
what is my problem? …
%% Loop start
numRows = length(shiftedDistance);
numCols = app.MaxMeasCountEditField.Value;
if isempty(app.dataMatrix)
app.dataMatrix = nan(numRows, numCols);
end
app.stop_loop = false;
if isempty(app.Ascan_cnt)
app.Ascan_cnt = 0;
end
while app.Ascan_cnt <= app.MaxMeasCountEditField.Value && app.stop_loop == false
% Add new data on the dataMatrix
if app.Ascan_cnt > numCols
% If I need to add cols
app.dataMatrix = [app.dataMatrix, nan(numRows, 1)];
numCols = numCols + 1;
end
app.dataMatrix(:, app.Ascan_cnt + 1) = newData;
% NaN to Zero
app.dataMatrix(isnan(app.dataMatrix)) = 0;
% image update
imagesc(app.UIAxes3_1, [1 app.Ascan_cnt], [min(shiftedDistance) max(shiftedDistance)], app.dataMatrix);
% xlim set
if app.Ascan_cnt > 50
xlim(app.UIAxes3_1, [app.Ascan_cnt – 49 app.Ascan_cnt]);
else
xlim(app.UIAxes3_1, [1 50]);
end
% ylim set
ylim(app.UIAxes3_1, [min(shiftedDistance) max(shiftedDistance)]);
colormap(app.UIAxes3_1, ‘gray’);
axis(app.UIAxes3_1, ‘tight’);
set(app.UIAxes3_1, ‘YDir’, ‘reverse’);
clim(app.UIAxes3_1, [0, app.ImageScalingEditField.Value]);
…
My code is like those.
I have a problem on setting the X axis in the Matlab appdesigner imagesc.
I want to add measured datas one by one on the defined Matrix.
And, I want the initial X axis with 50 components, and moving through when components are over 50s.
But, the datas add along arbitrary value even not integer.
what is my problem? appdesigner, imagesc, axis, matlab gui, matlab MATLAB Answers — New Questions
Error using sym>convertChar (line 1448)
Hi everyone,
I get the error message:
"Error using sym>convertChar (line 1448)
Character vectors and strings in the first argument can only specify a variable or number. To evaluate character vectors and
strings representing symbolic expressions, use ‘str2sym’.
Error in sym>tomupad (line 1214)
S = convertChar(x);
Error in sym (line 211)
S.s = tomupad(x);
Error in SolveExample>TurnEqIntoDEq (line 43)
depVarsLong(k) = sym([char(depVars(k)) ‘(‘ char(indepVar) ‘)’]);
Error in SolveExample (line 21)
[dEq3, initEq3] = TurnEqIntoDEq(Eq1, [a b c], t, 0);"
when I run the attached code. What can I do?Hi everyone,
I get the error message:
"Error using sym>convertChar (line 1448)
Character vectors and strings in the first argument can only specify a variable or number. To evaluate character vectors and
strings representing symbolic expressions, use ‘str2sym’.
Error in sym>tomupad (line 1214)
S = convertChar(x);
Error in sym (line 211)
S.s = tomupad(x);
Error in SolveExample>TurnEqIntoDEq (line 43)
depVarsLong(k) = sym([char(depVars(k)) ‘(‘ char(indepVar) ‘)’]);
Error in SolveExample (line 21)
[dEq3, initEq3] = TurnEqIntoDEq(Eq1, [a b c], t, 0);"
when I run the attached code. What can I do? Hi everyone,
I get the error message:
"Error using sym>convertChar (line 1448)
Character vectors and strings in the first argument can only specify a variable or number. To evaluate character vectors and
strings representing symbolic expressions, use ‘str2sym’.
Error in sym>tomupad (line 1214)
S = convertChar(x);
Error in sym (line 211)
S.s = tomupad(x);
Error in SolveExample>TurnEqIntoDEq (line 43)
depVarsLong(k) = sym([char(depVars(k)) ‘(‘ char(indepVar) ‘)’]);
Error in SolveExample (line 21)
[dEq3, initEq3] = TurnEqIntoDEq(Eq1, [a b c], t, 0);"
when I run the attached code. What can I do? solve, dsolve MATLAB Answers — New Questions
Is it possible to plot a SURFPoints or MSERRegions object using App Designer on UIAxes? Or any other Point Object?
I can execute these series of commands outside of app designer:
image is an imported BW jpeg. uint8 class Executing the below lines in the Command Window work great.
fixedPoints = detectSURFFeatures(image);
figure;imshow(image);
hold on
plot(fixedPoints);
However, executing these lines in the app designer results in an error:
imshow(image, ‘Parent’,app.UIAxes)% this works also with imshowpair or showMatchedFeatures
hold(app.UIAxes,"on");
plot(app.UIAxes, fixedPoints); % unfortunately this results in an error:
Error using plot
Data must be numeric, datetime, duration, categorical, or an array convertible to double.
I am running this code using Matlab 2024a, Update 2, on an Apple M2 Max with Ventura 13.4.1.
Might anyone know how to fix this or maybe a workaround?
ThanksI can execute these series of commands outside of app designer:
image is an imported BW jpeg. uint8 class Executing the below lines in the Command Window work great.
fixedPoints = detectSURFFeatures(image);
figure;imshow(image);
hold on
plot(fixedPoints);
However, executing these lines in the app designer results in an error:
imshow(image, ‘Parent’,app.UIAxes)% this works also with imshowpair or showMatchedFeatures
hold(app.UIAxes,"on");
plot(app.UIAxes, fixedPoints); % unfortunately this results in an error:
Error using plot
Data must be numeric, datetime, duration, categorical, or an array convertible to double.
I am running this code using Matlab 2024a, Update 2, on an Apple M2 Max with Ventura 13.4.1.
Might anyone know how to fix this or maybe a workaround?
Thanks I can execute these series of commands outside of app designer:
image is an imported BW jpeg. uint8 class Executing the below lines in the Command Window work great.
fixedPoints = detectSURFFeatures(image);
figure;imshow(image);
hold on
plot(fixedPoints);
However, executing these lines in the app designer results in an error:
imshow(image, ‘Parent’,app.UIAxes)% this works also with imshowpair or showMatchedFeatures
hold(app.UIAxes,"on");
plot(app.UIAxes, fixedPoints); % unfortunately this results in an error:
Error using plot
Data must be numeric, datetime, duration, categorical, or an array convertible to double.
I am running this code using Matlab 2024a, Update 2, on an Apple M2 Max with Ventura 13.4.1.
Might anyone know how to fix this or maybe a workaround?
Thanks uiaxes, plot point objects, image registration MATLAB Answers — New Questions
using PCA to filter outliers in MATLAB
A bit of a silly question (I suspect). I am using MATLAB to preprocess some bulk RNAseq data. I am calling PCA on my normalized counts just as an initial way to identify outliers I didn’t automatically reject. There are indeed some clear outliers but I am not sure how to use the score matrix output by pca to filter my original data because it is now in descending order of explained variance. How can I use the pca scores to return to the indicies of problematic samples. Thank you so much! Info below:
[coeff,score,latent,tsquared,explained] = pca(normCounts);
size(normCounts) 136 samples with 24427 measured genes
ans =
136 24427A bit of a silly question (I suspect). I am using MATLAB to preprocess some bulk RNAseq data. I am calling PCA on my normalized counts just as an initial way to identify outliers I didn’t automatically reject. There are indeed some clear outliers but I am not sure how to use the score matrix output by pca to filter my original data because it is now in descending order of explained variance. How can I use the pca scores to return to the indicies of problematic samples. Thank you so much! Info below:
[coeff,score,latent,tsquared,explained] = pca(normCounts);
size(normCounts) 136 samples with 24427 measured genes
ans =
136 24427 A bit of a silly question (I suspect). I am using MATLAB to preprocess some bulk RNAseq data. I am calling PCA on my normalized counts just as an initial way to identify outliers I didn’t automatically reject. There are indeed some clear outliers but I am not sure how to use the score matrix output by pca to filter my original data because it is now in descending order of explained variance. How can I use the pca scores to return to the indicies of problematic samples. Thank you so much! Info below:
[coeff,score,latent,tsquared,explained] = pca(normCounts);
size(normCounts) 136 samples with 24427 measured genes
ans =
136 24427 pca, rnaseq MATLAB Answers — New Questions
Need to change the direction of polar plot theta tick labels from counterclockwise to clockwise.
The audience for my polar plot is airplane pilots. If they face in the direction 000, then to their right is the direction 090 and to their left is 270. This is the opposite of the standard way MATLAB produces polar plots. To satisfy my audience, I need to change the direction of polar plot theta tick labels from counterclockwise to clockwise. How can this be done, please?The audience for my polar plot is airplane pilots. If they face in the direction 000, then to their right is the direction 090 and to their left is 270. This is the opposite of the standard way MATLAB produces polar plots. To satisfy my audience, I need to change the direction of polar plot theta tick labels from counterclockwise to clockwise. How can this be done, please? The audience for my polar plot is airplane pilots. If they face in the direction 000, then to their right is the direction 090 and to their left is 270. This is the opposite of the standard way MATLAB produces polar plots. To satisfy my audience, I need to change the direction of polar plot theta tick labels from counterclockwise to clockwise. How can this be done, please? direction of polar tick labels MATLAB Answers — New Questions
which way should I choose for app development ?
Hi,
I am making on app.
How can I decide that which way should I use from following ways :
GUIDE
Porgramatically
App Designer
On the bases of which factor should I take the decesionHi,
I am making on app.
How can I decide that which way should I use from following ways :
GUIDE
Porgramatically
App Designer
On the bases of which factor should I take the decesion Hi,
I am making on app.
How can I decide that which way should I use from following ways :
GUIDE
Porgramatically
App Designer
On the bases of which factor should I take the decesion guide, matlab gui, appdesigner MATLAB Answers — New Questions
Euler’s Method using a for loop
I am trying to produce a graph of displacement vs. velocity of a falling parachuter and produce tabulated values. I have been given the function–which I have attached a screenshot of. My code is currently producing the error: "Array indices must be positive integers or logical values.
My Code:
clear all
%initial conditions
g0 = 9.81; %m/s^2
R = 6.37e6; %m
h = 10000; %Step Size in m
x = 0 : h : 100000; % Range of X values
v = zeros(size(x));
vi = 1400; %m/s Initial velocity
n = numel(v); % Number of values for velocity
for i=1:n-1
v(x(i+1)) = v(x(i)) + ((g0/v(x(i))) * (R^2/ ((R + x(i))^2))) * (x(i+1) – x(i));
end
plot (x(i),v(i))I am trying to produce a graph of displacement vs. velocity of a falling parachuter and produce tabulated values. I have been given the function–which I have attached a screenshot of. My code is currently producing the error: "Array indices must be positive integers or logical values.
My Code:
clear all
%initial conditions
g0 = 9.81; %m/s^2
R = 6.37e6; %m
h = 10000; %Step Size in m
x = 0 : h : 100000; % Range of X values
v = zeros(size(x));
vi = 1400; %m/s Initial velocity
n = numel(v); % Number of values for velocity
for i=1:n-1
v(x(i+1)) = v(x(i)) + ((g0/v(x(i))) * (R^2/ ((R + x(i))^2))) * (x(i+1) – x(i));
end
plot (x(i),v(i)) I am trying to produce a graph of displacement vs. velocity of a falling parachuter and produce tabulated values. I have been given the function–which I have attached a screenshot of. My code is currently producing the error: "Array indices must be positive integers or logical values.
My Code:
clear all
%initial conditions
g0 = 9.81; %m/s^2
R = 6.37e6; %m
h = 10000; %Step Size in m
x = 0 : h : 100000; % Range of X values
v = zeros(size(x));
vi = 1400; %m/s Initial velocity
n = numel(v); % Number of values for velocity
for i=1:n-1
v(x(i+1)) = v(x(i)) + ((g0/v(x(i))) * (R^2/ ((R + x(i))^2))) * (x(i+1) – x(i));
end
plot (x(i),v(i)) euler, for loop MATLAB Answers — New Questions
How to combine cell arrays to form one nested cell array entry
Hello, I have a variable (X) that is a cell array (size 64X634). In the each location of cell array X, there is a nested 1×2 cell array.
How can I combinethe nested 1×2 cell arrays across the 634 columns in X such that the variable(X) is now the desired size of 64×1, where each row entry of the cell arrray X contains the new 634×2 nested cell array?
In other words, I want to combine each of the 1×2 cell arrays found in the columns of the original variable(X) so that each row of variable(X) only has one column (now a nested cell array with all the original 1×2 nested cell arrays). Thanks!Hello, I have a variable (X) that is a cell array (size 64X634). In the each location of cell array X, there is a nested 1×2 cell array.
How can I combinethe nested 1×2 cell arrays across the 634 columns in X such that the variable(X) is now the desired size of 64×1, where each row entry of the cell arrray X contains the new 634×2 nested cell array?
In other words, I want to combine each of the 1×2 cell arrays found in the columns of the original variable(X) so that each row of variable(X) only has one column (now a nested cell array with all the original 1×2 nested cell arrays). Thanks! Hello, I have a variable (X) that is a cell array (size 64X634). In the each location of cell array X, there is a nested 1×2 cell array.
How can I combinethe nested 1×2 cell arrays across the 634 columns in X such that the variable(X) is now the desired size of 64×1, where each row entry of the cell arrray X contains the new 634×2 nested cell array?
In other words, I want to combine each of the 1×2 cell arrays found in the columns of the original variable(X) so that each row of variable(X) only has one column (now a nested cell array with all the original 1×2 nested cell arrays). Thanks! nested cell arrays, concatenate cell arrays MATLAB Answers — New Questions
App Designer: prevent string truncation (uilabel, etc..)
Hi,
I have an app designed in App Designer 2018b. The same exact code ran in Matlab 2024a truncates strings with ellipsis (…) while 2018b does not.
How can I prevent this to happen? I do NOT want the string truncated, as the built-in function that does so seems unoptimized, as can be seen in screenshot below.
As you can see on the 2018b screenshot, the text has plenty of space to be fully displayed. Yet 2024a believes it needs to be truncated. Uilabel does not have Wordwrap, how to let user chose whether or not to truncate?Hi,
I have an app designed in App Designer 2018b. The same exact code ran in Matlab 2024a truncates strings with ellipsis (…) while 2018b does not.
How can I prevent this to happen? I do NOT want the string truncated, as the built-in function that does so seems unoptimized, as can be seen in screenshot below.
As you can see on the 2018b screenshot, the text has plenty of space to be fully displayed. Yet 2024a believes it needs to be truncated. Uilabel does not have Wordwrap, how to let user chose whether or not to truncate? Hi,
I have an app designed in App Designer 2018b. The same exact code ran in Matlab 2024a truncates strings with ellipsis (…) while 2018b does not.
How can I prevent this to happen? I do NOT want the string truncated, as the built-in function that does so seems unoptimized, as can be seen in screenshot below.
As you can see on the 2018b screenshot, the text has plenty of space to be fully displayed. Yet 2024a believes it needs to be truncated. Uilabel does not have Wordwrap, how to let user chose whether or not to truncate? uilabel, truncate MATLAB Answers — New Questions
Change date from cell to number inside array
I have data inside an array including strings and dates. The times appear to be in a cell inside the array.
The times appear from 0 to 1, which I understand. This data is brought from Excel which I must use.
The problem is I want to do an if statement inside this array to see which entries are larger than 10pm (approximately 0.9).
Whenever I try and use an if statement, I get an error because the times are stored in a cell format inside the array. How do I change it from a cell to a numeric format I can use?I have data inside an array including strings and dates. The times appear to be in a cell inside the array.
The times appear from 0 to 1, which I understand. This data is brought from Excel which I must use.
The problem is I want to do an if statement inside this array to see which entries are larger than 10pm (approximately 0.9).
Whenever I try and use an if statement, I get an error because the times are stored in a cell format inside the array. How do I change it from a cell to a numeric format I can use? I have data inside an array including strings and dates. The times appear to be in a cell inside the array.
The times appear from 0 to 1, which I understand. This data is brought from Excel which I must use.
The problem is I want to do an if statement inside this array to see which entries are larger than 10pm (approximately 0.9).
Whenever I try and use an if statement, I get an error because the times are stored in a cell format inside the array. How do I change it from a cell to a numeric format I can use? time, datetime, cell, cell array MATLAB Answers — New Questions
Derivative of table between NaN values
I have data in a table, in between there are NaN values.
I want to calculate the derivatives (using the 1st column as x’s and 2nd column as y’s ) between each NaN space and put these values into a new vector.
Thanks!I have data in a table, in between there are NaN values.
I want to calculate the derivatives (using the 1st column as x’s and 2nd column as y’s ) between each NaN space and put these values into a new vector.
Thanks! I have data in a table, in between there are NaN values.
I want to calculate the derivatives (using the 1st column as x’s and 2nd column as y’s ) between each NaN space and put these values into a new vector.
Thanks! derivative, tables, cells MATLAB Answers — New Questions
AppDesigner UIFigure WindowScrollWheelFcn disables datatips
I am building an app in AppDesigner r2021a. I have several plots with custom datatips on different tabs. Everything works great.
However, when I add a WindowScrollWheelFcn callback to the parent uifigure, I am no longer able to see datatips when hovering over points.
Is there anyway around this?I am building an app in AppDesigner r2021a. I have several plots with custom datatips on different tabs. Everything works great.
However, when I add a WindowScrollWheelFcn callback to the parent uifigure, I am no longer able to see datatips when hovering over points.
Is there anyway around this? I am building an app in AppDesigner r2021a. I have several plots with custom datatips on different tabs. Everything works great.
However, when I add a WindowScrollWheelFcn callback to the parent uifigure, I am no longer able to see datatips when hovering over points.
Is there anyway around this? appdesigner, windowscrollwheelfcn, callback, datatip MATLAB Answers — New Questions
How do I change the font size of text in a figure?
I want to change the font size for the title, axis labels, and other text in my figure. How do I do this?I want to change the font size for the title, axis labels, and other text in my figure. How do I do this? I want to change the font size for the title, axis labels, and other text in my figure. How do I do this? MATLAB Answers — New Questions
Problem using loadlibrary in R2023B Update 7 and VS 2022 v17.9
I just updated my VS 2022 Enterprise from version 17.8 to 17.9.0 and I am having a problem using loadlibrary. It cannot find C header files and runtime libraries, possibly due to 17.9 shipping with a new MSVC version 14.39.33519 instead of the 14.38 version that comes with 17.8. How do I retarget loadlibrary to use the new version?I just updated my VS 2022 Enterprise from version 17.8 to 17.9.0 and I am having a problem using loadlibrary. It cannot find C header files and runtime libraries, possibly due to 17.9 shipping with a new MSVC version 14.39.33519 instead of the 14.38 version that comes with 17.8. How do I retarget loadlibrary to use the new version? I just updated my VS 2022 Enterprise from version 17.8 to 17.9.0 and I am having a problem using loadlibrary. It cannot find C header files and runtime libraries, possibly due to 17.9 shipping with a new MSVC version 14.39.33519 instead of the 14.38 version that comes with 17.8. How do I retarget loadlibrary to use the new version? loadlibrary MATLAB Answers — New Questions
Checkbox in header row for uitable
Is it possible to put a checkbox next to a string in the same column?
I have a table, and one of the column are checkboxes. I want another checkbox that when checked will check all the other checkboxes. I know how to do this, but I what I would really like is to put this checkbox at the header row of the uitable. Maybe even add a string before the checkbox?
Is this even possible?Is it possible to put a checkbox next to a string in the same column?
I have a table, and one of the column are checkboxes. I want another checkbox that when checked will check all the other checkboxes. I know how to do this, but I what I would really like is to put this checkbox at the header row of the uitable. Maybe even add a string before the checkbox?
Is this even possible? Is it possible to put a checkbox next to a string in the same column?
I have a table, and one of the column are checkboxes. I want another checkbox that when checked will check all the other checkboxes. I know how to do this, but I what I would really like is to put this checkbox at the header row of the uitable. Maybe even add a string before the checkbox?
Is this even possible? appdesigner, checkbox, uitable MATLAB Answers — New Questions
MATLAB 2021a produces a compilation error on older MATLAB code.
I have a MATLAB application written in MATLAB 2019a which I can compile into a .exe. I wish to port the code to 2021a. The application can be opened and closed without issues. But when I try to compile the code using mcc for 2021a, I get the following error message which I don’t get when using 2019a.
Compiler version: 8.2 (R2021a)
Analyzing file dependencies.
Error while determining required deployable files. Compilation terminated. Details:
Unable to resolve the name dependencies.internal.graph.Node.createFileNode.
How do I debug this ?I have a MATLAB application written in MATLAB 2019a which I can compile into a .exe. I wish to port the code to 2021a. The application can be opened and closed without issues. But when I try to compile the code using mcc for 2021a, I get the following error message which I don’t get when using 2019a.
Compiler version: 8.2 (R2021a)
Analyzing file dependencies.
Error while determining required deployable files. Compilation terminated. Details:
Unable to resolve the name dependencies.internal.graph.Node.createFileNode.
How do I debug this ? I have a MATLAB application written in MATLAB 2019a which I can compile into a .exe. I wish to port the code to 2021a. The application can be opened and closed without issues. But when I try to compile the code using mcc for 2021a, I get the following error message which I don’t get when using 2019a.
Compiler version: 8.2 (R2021a)
Analyzing file dependencies.
Error while determining required deployable files. Compilation terminated. Details:
Unable to resolve the name dependencies.internal.graph.Node.createFileNode.
How do I debug this ? mcc, matlab compiler, 2021a MATLAB Answers — New Questions