Tag Archives: matlab
Is there a way to rename a file to one that contains certain strings?
For example, we have the following variables stored:
Altitude = 100ft
Mach=0.1
And suppose the script called output.txt.
Is there a way to, at the end of the run, rename the output.txt file to be called Output2000ft0.7m.txt so that it doesn’t get overwritten on the next run?For example, we have the following variables stored:
Altitude = 100ft
Mach=0.1
And suppose the script called output.txt.
Is there a way to, at the end of the run, rename the output.txt file to be called Output2000ft0.7m.txt so that it doesn’t get overwritten on the next run? For example, we have the following variables stored:
Altitude = 100ft
Mach=0.1
And suppose the script called output.txt.
Is there a way to, at the end of the run, rename the output.txt file to be called Output2000ft0.7m.txt so that it doesn’t get overwritten on the next run? matlab code, matlab function MATLAB Answers — New Questions
Solve a system of two variable inequalities with symbolic toolbox
Hello,
is it possible to symbolically solve a system of inequalities with variables x and y and plot the result?
lets say i have to solve x+y-25>0 and x*y+y+15>0, what function should i use?
i have tried fimplicit plus assumptions but it didn’t work.
thank youHello,
is it possible to symbolically solve a system of inequalities with variables x and y and plot the result?
lets say i have to solve x+y-25>0 and x*y+y+15>0, what function should i use?
i have tried fimplicit plus assumptions but it didn’t work.
thank you Hello,
is it possible to symbolically solve a system of inequalities with variables x and y and plot the result?
lets say i have to solve x+y-25>0 and x*y+y+15>0, what function should i use?
i have tried fimplicit plus assumptions but it didn’t work.
thank you symbolic math toolbox, inequalities, plotting, implicit MATLAB Answers — New Questions
How to initialize instance of object in Simulink Global Workspace?
Hello,
I am aiming to create an object (instance of class) in the Simulink Global Workspace via code in the Preload Fcn Callback.
This simulink model is using a Matlab Function block to input the parameters of an object to an S-Funciton block that is tied to a larger external simulation, and then the output of this simulation is passed back to another Matlab Function block that re-initializes the data with the results, and repeats until finished. Initially, I had used Interpreted Matlab Function blocks to pass this data back and forth but I am now forced to switch out of them and decided upon Matlab function blocks. I have made all the underlying code code-generation compatible, but I am having trouble intializing in object via the global workspace in Simulink.
In my preload function callback, I simply just write:
var_name = ObjClass();
I am then aiming to call methods/functions to manipulate the properties of this object in a Matlab Function block. For instance, in my initial Matlab Function block (which has no inputs), the code is like:
function output = fcn()
output = var_name.func_name();
end
However, whenever I run the simulation, I am getting the erro that var_name.func_name() is an undefined function or variable.
Can’t seem to figure out why the instance of class is not being created in the preload function as the Simulink is unchanged from successful use with Interpreted Matlab function blocks. Is there some sort of difference underlying the Matlab Function block that I am missing? Global Declarations?
Thanks!Hello,
I am aiming to create an object (instance of class) in the Simulink Global Workspace via code in the Preload Fcn Callback.
This simulink model is using a Matlab Function block to input the parameters of an object to an S-Funciton block that is tied to a larger external simulation, and then the output of this simulation is passed back to another Matlab Function block that re-initializes the data with the results, and repeats until finished. Initially, I had used Interpreted Matlab Function blocks to pass this data back and forth but I am now forced to switch out of them and decided upon Matlab function blocks. I have made all the underlying code code-generation compatible, but I am having trouble intializing in object via the global workspace in Simulink.
In my preload function callback, I simply just write:
var_name = ObjClass();
I am then aiming to call methods/functions to manipulate the properties of this object in a Matlab Function block. For instance, in my initial Matlab Function block (which has no inputs), the code is like:
function output = fcn()
output = var_name.func_name();
end
However, whenever I run the simulation, I am getting the erro that var_name.func_name() is an undefined function or variable.
Can’t seem to figure out why the instance of class is not being created in the preload function as the Simulink is unchanged from successful use with Interpreted Matlab function blocks. Is there some sort of difference underlying the Matlab Function block that I am missing? Global Declarations?
Thanks! Hello,
I am aiming to create an object (instance of class) in the Simulink Global Workspace via code in the Preload Fcn Callback.
This simulink model is using a Matlab Function block to input the parameters of an object to an S-Funciton block that is tied to a larger external simulation, and then the output of this simulation is passed back to another Matlab Function block that re-initializes the data with the results, and repeats until finished. Initially, I had used Interpreted Matlab Function blocks to pass this data back and forth but I am now forced to switch out of them and decided upon Matlab function blocks. I have made all the underlying code code-generation compatible, but I am having trouble intializing in object via the global workspace in Simulink.
In my preload function callback, I simply just write:
var_name = ObjClass();
I am then aiming to call methods/functions to manipulate the properties of this object in a Matlab Function block. For instance, in my initial Matlab Function block (which has no inputs), the code is like:
function output = fcn()
output = var_name.func_name();
end
However, whenever I run the simulation, I am getting the erro that var_name.func_name() is an undefined function or variable.
Can’t seem to figure out why the instance of class is not being created in the preload function as the Simulink is unchanged from successful use with Interpreted Matlab function blocks. Is there some sort of difference underlying the Matlab Function block that I am missing? Global Declarations?
Thanks! simulink, object oriented programming, matlab function, s-function MATLAB Answers — New Questions
Stateflow – functions not connected to other blocks
Hi!
I am trying to create a vehicle body on Simulink, and I am using Stateflow for the gearbox control (following the MathWorks example: https://uk.mathworks.com/help/sdl/ug/about-the-complete-vehicle-model.html)
I have trouble creating the Stateflow subsystem, as the UP/DOWN in my Bloc 1 don’t seem to be connected to the ones in the selection state. From the model available online (link above), it seems like I am only missing the yellow colour on these words in order for them to be linked and refered to in the gear selection state. The Stateflow models and examples available online all use this "yellow" feature, so I think it is quite easy to use once you know how to do it, but I can’t see how to do it.
Would anyone be able to help me?
Thanks in advance!Hi!
I am trying to create a vehicle body on Simulink, and I am using Stateflow for the gearbox control (following the MathWorks example: https://uk.mathworks.com/help/sdl/ug/about-the-complete-vehicle-model.html)
I have trouble creating the Stateflow subsystem, as the UP/DOWN in my Bloc 1 don’t seem to be connected to the ones in the selection state. From the model available online (link above), it seems like I am only missing the yellow colour on these words in order for them to be linked and refered to in the gear selection state. The Stateflow models and examples available online all use this "yellow" feature, so I think it is quite easy to use once you know how to do it, but I can’t see how to do it.
Would anyone be able to help me?
Thanks in advance! Hi!
I am trying to create a vehicle body on Simulink, and I am using Stateflow for the gearbox control (following the MathWorks example: https://uk.mathworks.com/help/sdl/ug/about-the-complete-vehicle-model.html)
I have trouble creating the Stateflow subsystem, as the UP/DOWN in my Bloc 1 don’t seem to be connected to the ones in the selection state. From the model available online (link above), it seems like I am only missing the yellow colour on these words in order for them to be linked and refered to in the gear selection state. The Stateflow models and examples available online all use this "yellow" feature, so I think it is quite easy to use once you know how to do it, but I can’t see how to do it.
Would anyone be able to help me?
Thanks in advance! stateflow, performance MATLAB Answers — New Questions
.CSV plugin for EEGlab that isn’t mentalab?
Mentalab plugin requires 3 .CSV files that are imported in tandem. I am not using a mentalab system and was wondering if there were any other plugins that allow EEGLAB to import data from a singular .csv file.Mentalab plugin requires 3 .CSV files that are imported in tandem. I am not using a mentalab system and was wondering if there were any other plugins that allow EEGLAB to import data from a singular .csv file. Mentalab plugin requires 3 .CSV files that are imported in tandem. I am not using a mentalab system and was wondering if there were any other plugins that allow EEGLAB to import data from a singular .csv file. eeglab MATLAB Answers — New Questions
Psychtoolbox- Error Using Screen
Hi everyone, I’m encountering an issue with a section of code from a script. It keeps closing out with an error, and I’m not sure why. The error message reads as follows:
Error using Screen
Usage:
Screen(‘DrawTexture’, windowPointer, texturePointer [,sourceRect] [,destinationRect] [,rotationAngle] [, filterMode] [, globalAlpha] [, modulateColor] [, textureShader] [, specialFlags] [,
auxParameters]);
Error in memcongr (line 802)
Screen(‘DrawTexture’, window, leftStimuli{iTrial}, [], LeftPatch{iTrial});
The variables leftStimuli & LeftPatch are defined as:
leftStimuli = cell(1,nruns);
LeftPatch = cell(1,length(rightselection{oldtrialsperrun}));
Also, these variables are defined as:
oldtrialsperrun:
oldtrialsperrun = 5;
luretrialsperrun= 3;
nTrialsTotal = oldtrialsperrun + luretrialsperrun;
rightselection
images_encoding_stim = Shuffle(stimuli);
leftStimuli = cell(1,nruns);
RightStimuli = cell(1,nruns);
% Ensure the equality of the number of stimuli
total_stimuli = length(images_encoding_stim);
half_stimuli = floor(total_stimuli / 2);
% Divide into two groups: right position and left position
rightselection = images_encoding_stim(1:half_stimuli);
leftselection = images_encoding_stim(half_stimuli+1:end);
clear half_stimuli
% Divide for each run (here you get a code with the stimuli you need to present on the right and left sides)
for irun = 1:nruns
stimuliPerRunRight{irun} = {rightselection(1+(irun-1)*oldtrialsperrun : irun*oldtrialsperrun)};
stimuliPerRunLeft{irun} = {leftselection(1+(irun-1)*oldtrialsperrun : irun*oldtrialsperrun)};
end
Thank you very much for everything. I’ve been stuck with this error for a couple of months. I’m very willing and open to answering questions about any part of the code in order to get it working.Hi everyone, I’m encountering an issue with a section of code from a script. It keeps closing out with an error, and I’m not sure why. The error message reads as follows:
Error using Screen
Usage:
Screen(‘DrawTexture’, windowPointer, texturePointer [,sourceRect] [,destinationRect] [,rotationAngle] [, filterMode] [, globalAlpha] [, modulateColor] [, textureShader] [, specialFlags] [,
auxParameters]);
Error in memcongr (line 802)
Screen(‘DrawTexture’, window, leftStimuli{iTrial}, [], LeftPatch{iTrial});
The variables leftStimuli & LeftPatch are defined as:
leftStimuli = cell(1,nruns);
LeftPatch = cell(1,length(rightselection{oldtrialsperrun}));
Also, these variables are defined as:
oldtrialsperrun:
oldtrialsperrun = 5;
luretrialsperrun= 3;
nTrialsTotal = oldtrialsperrun + luretrialsperrun;
rightselection
images_encoding_stim = Shuffle(stimuli);
leftStimuli = cell(1,nruns);
RightStimuli = cell(1,nruns);
% Ensure the equality of the number of stimuli
total_stimuli = length(images_encoding_stim);
half_stimuli = floor(total_stimuli / 2);
% Divide into two groups: right position and left position
rightselection = images_encoding_stim(1:half_stimuli);
leftselection = images_encoding_stim(half_stimuli+1:end);
clear half_stimuli
% Divide for each run (here you get a code with the stimuli you need to present on the right and left sides)
for irun = 1:nruns
stimuliPerRunRight{irun} = {rightselection(1+(irun-1)*oldtrialsperrun : irun*oldtrialsperrun)};
stimuliPerRunLeft{irun} = {leftselection(1+(irun-1)*oldtrialsperrun : irun*oldtrialsperrun)};
end
Thank you very much for everything. I’ve been stuck with this error for a couple of months. I’m very willing and open to answering questions about any part of the code in order to get it working. Hi everyone, I’m encountering an issue with a section of code from a script. It keeps closing out with an error, and I’m not sure why. The error message reads as follows:
Error using Screen
Usage:
Screen(‘DrawTexture’, windowPointer, texturePointer [,sourceRect] [,destinationRect] [,rotationAngle] [, filterMode] [, globalAlpha] [, modulateColor] [, textureShader] [, specialFlags] [,
auxParameters]);
Error in memcongr (line 802)
Screen(‘DrawTexture’, window, leftStimuli{iTrial}, [], LeftPatch{iTrial});
The variables leftStimuli & LeftPatch are defined as:
leftStimuli = cell(1,nruns);
LeftPatch = cell(1,length(rightselection{oldtrialsperrun}));
Also, these variables are defined as:
oldtrialsperrun:
oldtrialsperrun = 5;
luretrialsperrun= 3;
nTrialsTotal = oldtrialsperrun + luretrialsperrun;
rightselection
images_encoding_stim = Shuffle(stimuli);
leftStimuli = cell(1,nruns);
RightStimuli = cell(1,nruns);
% Ensure the equality of the number of stimuli
total_stimuli = length(images_encoding_stim);
half_stimuli = floor(total_stimuli / 2);
% Divide into two groups: right position and left position
rightselection = images_encoding_stim(1:half_stimuli);
leftselection = images_encoding_stim(half_stimuli+1:end);
clear half_stimuli
% Divide for each run (here you get a code with the stimuli you need to present on the right and left sides)
for irun = 1:nruns
stimuliPerRunRight{irun} = {rightselection(1+(irun-1)*oldtrialsperrun : irun*oldtrialsperrun)};
stimuliPerRunLeft{irun} = {leftselection(1+(irun-1)*oldtrialsperrun : irun*oldtrialsperrun)};
end
Thank you very much for everything. I’ve been stuck with this error for a couple of months. I’m very willing and open to answering questions about any part of the code in order to get it working. psychtoolbox, screen MATLAB Answers — New Questions
What is the RoadRunner Maximum Map Size?
What is the maximum building area in RoadRunner? The default grid is 2000 x 2000 m, can I make that larger?What is the maximum building area in RoadRunner? The default grid is 2000 x 2000 m, can I make that larger? What is the maximum building area in RoadRunner? The default grid is 2000 x 2000 m, can I make that larger? roadrunner, mapsize, map, size, grid, gridsize MATLAB Answers — New Questions
My code runs in script and not in app design
Hi I wrote a code in script and it works but when I copy the exact code in app design it give me the error:" Error using ./ Arrays have incompatible sizes for this operation. Help plsHi I wrote a code in script and it works but when I copy the exact code in app design it give me the error:" Error using ./ Arrays have incompatible sizes for this operation. Help pls Hi I wrote a code in script and it works but when I copy the exact code in app design it give me the error:" Error using ./ Arrays have incompatible sizes for this operation. Help pls appdesigner, app designer MATLAB Answers — New Questions
ismember returning false for 0.6000 == 0.6
Hello,
I have a column of data that was created by using
A = 0.05:0.01:0.9
Secondly I am trying to obtain just the values of
B = [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9]
However when I run
[C idx] = ismember(B,A)
it returns the logical array
[1 1 1 1 1 0 1 1 1]
[6 16 26 36 46 0 66 76 86]
I have checked the workspace and confirmed that the value 0.6000 exists within A and even when I explicitly index it returns false
A(56)
returns
0.6000
and
A(56) == 0.6
returns logical 0.
Repeating this for the other values in B results in logical 1s as array C describes.
Thank you for any help you can provide!Hello,
I have a column of data that was created by using
A = 0.05:0.01:0.9
Secondly I am trying to obtain just the values of
B = [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9]
However when I run
[C idx] = ismember(B,A)
it returns the logical array
[1 1 1 1 1 0 1 1 1]
[6 16 26 36 46 0 66 76 86]
I have checked the workspace and confirmed that the value 0.6000 exists within A and even when I explicitly index it returns false
A(56)
returns
0.6000
and
A(56) == 0.6
returns logical 0.
Repeating this for the other values in B results in logical 1s as array C describes.
Thank you for any help you can provide! Hello,
I have a column of data that was created by using
A = 0.05:0.01:0.9
Secondly I am trying to obtain just the values of
B = [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9]
However when I run
[C idx] = ismember(B,A)
it returns the logical array
[1 1 1 1 1 0 1 1 1]
[6 16 26 36 46 0 66 76 86]
I have checked the workspace and confirmed that the value 0.6000 exists within A and even when I explicitly index it returns false
A(56)
returns
0.6000
and
A(56) == 0.6
returns logical 0.
Repeating this for the other values in B results in logical 1s as array C describes.
Thank you for any help you can provide! ismember, logical array, floating point MATLAB Answers — New Questions
can an example is provided to use Attention mechanism in time series sequence data? and also how to use it with LSTM?.
I have large time series sequence data, and I want to use attention mechanism for this data, and also concatenate the output of the attention mechanism with LSTM. Can any one help me in this regards by solving an example?I have large time series sequence data, and I want to use attention mechanism for this data, and also concatenate the output of the attention mechanism with LSTM. Can any one help me in this regards by solving an example? I have large time series sequence data, and I want to use attention mechanism for this data, and also concatenate the output of the attention mechanism with LSTM. Can any one help me in this regards by solving an example? deep learning, attention mechanism MATLAB Answers — New Questions
Vectorization for Two Nested for-loops
Hello all,
I’m trying to vectorize some operation between two 2D matrices, A and B. Basically, the process is multiplying every row verctor from matrix B by every vector from matrix A and store the value in matrix C. The correct non-vectorized code looks as follows:
A = [2 3 4; 5 2 1; 1 4 3];
B = [3 4 4; 4 2 1; 4 4 1];
C = zeros(3,3); % Initializing C
for ii=1:size(A,1)
for jj=1:size(B,1)
AA = A(ii,:);
BB = transpose(B(jj,:));
C(jj,ii) = sum(BB*AA, ‘all’)
end
end
C
The resultant C should looks as:
C =
99 88 88
63 56 56
81 72 72
Can I get help here?
Thanks!Hello all,
I’m trying to vectorize some operation between two 2D matrices, A and B. Basically, the process is multiplying every row verctor from matrix B by every vector from matrix A and store the value in matrix C. The correct non-vectorized code looks as follows:
A = [2 3 4; 5 2 1; 1 4 3];
B = [3 4 4; 4 2 1; 4 4 1];
C = zeros(3,3); % Initializing C
for ii=1:size(A,1)
for jj=1:size(B,1)
AA = A(ii,:);
BB = transpose(B(jj,:));
C(jj,ii) = sum(BB*AA, ‘all’)
end
end
C
The resultant C should looks as:
C =
99 88 88
63 56 56
81 72 72
Can I get help here?
Thanks! Hello all,
I’m trying to vectorize some operation between two 2D matrices, A and B. Basically, the process is multiplying every row verctor from matrix B by every vector from matrix A and store the value in matrix C. The correct non-vectorized code looks as follows:
A = [2 3 4; 5 2 1; 1 4 3];
B = [3 4 4; 4 2 1; 4 4 1];
C = zeros(3,3); % Initializing C
for ii=1:size(A,1)
for jj=1:size(B,1)
AA = A(ii,:);
BB = transpose(B(jj,:));
C(jj,ii) = sum(BB*AA, ‘all’)
end
end
C
The resultant C should looks as:
C =
99 88 88
63 56 56
81 72 72
Can I get help here?
Thanks! vectorization MATLAB Answers — New Questions
How to control multiple hardware units simultaneously?
I am trying to contol one Technica Gateway and DC Power supply. I wrote a matlab code to control them individually. But, if I tried control them simultaneously, one of the device is going to busy state. But, I want both to be operated at same time and there should be synchronization between them. Can someone help me to resolve the issue?I am trying to contol one Technica Gateway and DC Power supply. I wrote a matlab code to control them individually. But, if I tried control them simultaneously, one of the device is going to busy state. But, I want both to be operated at same time and there should be synchronization between them. Can someone help me to resolve the issue? I am trying to contol one Technica Gateway and DC Power supply. I wrote a matlab code to control them individually. But, if I tried control them simultaneously, one of the device is going to busy state. But, I want both to be operated at same time and there should be synchronization between them. Can someone help me to resolve the issue? signal processing, parallel computing, instrument control MATLAB Answers — New Questions
how to add goto from block and connected to the ports of a existed simulink system programmtically
hello,i have a simulink subsystem with some port defined inside, for example it has two inports and two outports,now i want add from block and connected to the inport,add goto block and connect to the outport,both goto block and from block should be named same as the connected port,how to do this?hello,i have a simulink subsystem with some port defined inside, for example it has two inports and two outports,now i want add from block and connected to the inport,add goto block and connect to the outport,both goto block and from block should be named same as the connected port,how to do this? hello,i have a simulink subsystem with some port defined inside, for example it has two inports and two outports,now i want add from block and connected to the inport,add goto block and connect to the outport,both goto block and from block should be named same as the connected port,how to do this? simulink port connect, goto from MATLAB Answers — New Questions
Can we use ‘sequenceInputLayer(inputSize)’ with ‘featureInputLayer’ in multiple input deep convolutional neural network?
I am using a network with multiple input CNN network, where one is sequence input and second one is feature input. The combined datastore was created as follows:
dsX1Train = arrayDatastore(XTrainD);
dsX2Train = arrayDatastore(XTrainf);
dsTTrain = arrayDatastore(XTrainL);
dsTrain = combine(dsX1Train,dsX2Train,dsTTrain);
Here ‘XTrainD’ is of size 800-by-1 cell where each row consists of 1-by-1-by-800 (single) sequence data. ‘XTrainf’ is feature of 800-by-1 (single) data and ‘XTrainL’ is the categorical data for labels of size 800-by-1. During training using trainnet(),
options = trainingOptions(‘adam’,…
‘Shuffle’,’every-epoch’,…
‘InputDataFormats’,{‘CBT’,’BC’},…
‘MaxEpochs’,50,…
‘MiniBatchSize’,16,…
‘InitialLearnRate’,1e-4,…
‘Verbose’,1,…
‘ExecutionEnvironment’,’cpu’,…
‘Plots’,’training-progress’);
net = trainnet(dsTrain,layer,"crossentropy",options);
some error is shown as below,
Error using trainnet (line 46)
Error forming mini-batch for network input "input_1". Data interpreted with format "CBT". To specify a different format, use the InputDataFormats option.
Caused by:
Input sequences must be numeric or categorical arrays.
Am I creating data and the datastore in the right way? Is it possible to train multiple input network using trainnet with one input as sequence input layer? I have used Train Network on Image and Feature Data – MATLAB & Simulink – MathWorks for the reference.
Thanking in advance for the help.I am using a network with multiple input CNN network, where one is sequence input and second one is feature input. The combined datastore was created as follows:
dsX1Train = arrayDatastore(XTrainD);
dsX2Train = arrayDatastore(XTrainf);
dsTTrain = arrayDatastore(XTrainL);
dsTrain = combine(dsX1Train,dsX2Train,dsTTrain);
Here ‘XTrainD’ is of size 800-by-1 cell where each row consists of 1-by-1-by-800 (single) sequence data. ‘XTrainf’ is feature of 800-by-1 (single) data and ‘XTrainL’ is the categorical data for labels of size 800-by-1. During training using trainnet(),
options = trainingOptions(‘adam’,…
‘Shuffle’,’every-epoch’,…
‘InputDataFormats’,{‘CBT’,’BC’},…
‘MaxEpochs’,50,…
‘MiniBatchSize’,16,…
‘InitialLearnRate’,1e-4,…
‘Verbose’,1,…
‘ExecutionEnvironment’,’cpu’,…
‘Plots’,’training-progress’);
net = trainnet(dsTrain,layer,"crossentropy",options);
some error is shown as below,
Error using trainnet (line 46)
Error forming mini-batch for network input "input_1". Data interpreted with format "CBT". To specify a different format, use the InputDataFormats option.
Caused by:
Input sequences must be numeric or categorical arrays.
Am I creating data and the datastore in the right way? Is it possible to train multiple input network using trainnet with one input as sequence input layer? I have used Train Network on Image and Feature Data – MATLAB & Simulink – MathWorks for the reference.
Thanking in advance for the help. I am using a network with multiple input CNN network, where one is sequence input and second one is feature input. The combined datastore was created as follows:
dsX1Train = arrayDatastore(XTrainD);
dsX2Train = arrayDatastore(XTrainf);
dsTTrain = arrayDatastore(XTrainL);
dsTrain = combine(dsX1Train,dsX2Train,dsTTrain);
Here ‘XTrainD’ is of size 800-by-1 cell where each row consists of 1-by-1-by-800 (single) sequence data. ‘XTrainf’ is feature of 800-by-1 (single) data and ‘XTrainL’ is the categorical data for labels of size 800-by-1. During training using trainnet(),
options = trainingOptions(‘adam’,…
‘Shuffle’,’every-epoch’,…
‘InputDataFormats’,{‘CBT’,’BC’},…
‘MaxEpochs’,50,…
‘MiniBatchSize’,16,…
‘InitialLearnRate’,1e-4,…
‘Verbose’,1,…
‘ExecutionEnvironment’,’cpu’,…
‘Plots’,’training-progress’);
net = trainnet(dsTrain,layer,"crossentropy",options);
some error is shown as below,
Error using trainnet (line 46)
Error forming mini-batch for network input "input_1". Data interpreted with format "CBT". To specify a different format, use the InputDataFormats option.
Caused by:
Input sequences must be numeric or categorical arrays.
Am I creating data and the datastore in the right way? Is it possible to train multiple input network using trainnet with one input as sequence input layer? I have used Train Network on Image and Feature Data – MATLAB & Simulink – MathWorks for the reference.
Thanking in advance for the help. signal processing, image analysis, image processing, image segmentation, deep learning, machine learning, neural network, neural networks, convolutional neural network, sequential input layer, feature input layer, trainnet, dlnetwork, training, testing MATLAB Answers — New Questions
stacked plot with 2 time series of different length and spacing
I have 2 time series. Both are different lengths (but they overlap for the first 1300s), and are sampled at different rates. Is there a way to plot this information on a stacked plot?
I want to be able to show the periodicity in the flucctuations so dont really want to plot them in subplot form.
files = dir(‘*.txt’);
N = length(files);
A = cell(1,N);
A2 = cell(1,N);
for ii = 1:max(size(files));
if files(ii).isdir ~=true
fname = files(ii).name;
file = fopen(fname);
A{ii} = cell2mat(textscan(file, ‘%f %f %f’));
fclose(file);
end
[~,idx] = unique(A{ii}(:,1));
A2{ii} = A{ii}(idx,:);
end
plot(A2{1}(:,2),A2{1}(:,3))
hold on
plot(A2{2}(:,2),A2{2}(:,3))
xlabel(‘Time (s)’)I have 2 time series. Both are different lengths (but they overlap for the first 1300s), and are sampled at different rates. Is there a way to plot this information on a stacked plot?
I want to be able to show the periodicity in the flucctuations so dont really want to plot them in subplot form.
files = dir(‘*.txt’);
N = length(files);
A = cell(1,N);
A2 = cell(1,N);
for ii = 1:max(size(files));
if files(ii).isdir ~=true
fname = files(ii).name;
file = fopen(fname);
A{ii} = cell2mat(textscan(file, ‘%f %f %f’));
fclose(file);
end
[~,idx] = unique(A{ii}(:,1));
A2{ii} = A{ii}(idx,:);
end
plot(A2{1}(:,2),A2{1}(:,3))
hold on
plot(A2{2}(:,2),A2{2}(:,3))
xlabel(‘Time (s)’) I have 2 time series. Both are different lengths (but they overlap for the first 1300s), and are sampled at different rates. Is there a way to plot this information on a stacked plot?
I want to be able to show the periodicity in the flucctuations so dont really want to plot them in subplot form.
files = dir(‘*.txt’);
N = length(files);
A = cell(1,N);
A2 = cell(1,N);
for ii = 1:max(size(files));
if files(ii).isdir ~=true
fname = files(ii).name;
file = fopen(fname);
A{ii} = cell2mat(textscan(file, ‘%f %f %f’));
fclose(file);
end
[~,idx] = unique(A{ii}(:,1));
A2{ii} = A{ii}(idx,:);
end
plot(A2{1}(:,2),A2{1}(:,3))
hold on
plot(A2{2}(:,2),A2{2}(:,3))
xlabel(‘Time (s)’) stacked plot, time series MATLAB Answers — New Questions
sol2 = bvp4c(@bvpexam2, @bcexam2, sol);
how to get second solution from this code.I ploted first solution for different values of alpha.
function Ibrardual
clc
clear all
Nt=0.5; Nb=0.5; Le=2; Pr=1; alpha=-0.2138; s=1; A=1;
%% solution in structure form
%First solution
sol = bvpinit(linspace(0,2,10), [1 0 0 0 0 0 0]);
sol1 = bvp4c(@bvpexam2, @bcexam2, sol);
x1 = sol1.x;
y1=sol.y;
plot(x1,y1(3,:),’b’);
hold on
result=(A)^-1/2*y1(3,1)
%% Here I define residual of boundary conditions
function res = bcexam2(y0, yinf)
res= [y0(1)-s; y0(2)-alpha; y0(4)-1; y0(6)-1;
yinf(2); yinf(4);yinf(6)];
end
%% First order ODEs are define here
function ysol = bvpexam2(x,y)
yy1 = -A*(y(1)*y(3)-(y(2))^2)-y(2);
yy2 = -Pr*(A*y(1)*y(5)+Nb*y(5)*y(7)+Nt*(y(5))^2);
yy3 = (-Le*A*(y(1)*y(7))-(Nt/Nb)*( -Pr*(A*y(1)*y(5)+Nb*y(5)*y(7)+Nt*(y(5))^2)));
ysol = [y(2); y(3); yy1;y(5);yy2;y(7);yy3];
end
endhow to get second solution from this code.I ploted first solution for different values of alpha.
function Ibrardual
clc
clear all
Nt=0.5; Nb=0.5; Le=2; Pr=1; alpha=-0.2138; s=1; A=1;
%% solution in structure form
%First solution
sol = bvpinit(linspace(0,2,10), [1 0 0 0 0 0 0]);
sol1 = bvp4c(@bvpexam2, @bcexam2, sol);
x1 = sol1.x;
y1=sol.y;
plot(x1,y1(3,:),’b’);
hold on
result=(A)^-1/2*y1(3,1)
%% Here I define residual of boundary conditions
function res = bcexam2(y0, yinf)
res= [y0(1)-s; y0(2)-alpha; y0(4)-1; y0(6)-1;
yinf(2); yinf(4);yinf(6)];
end
%% First order ODEs are define here
function ysol = bvpexam2(x,y)
yy1 = -A*(y(1)*y(3)-(y(2))^2)-y(2);
yy2 = -Pr*(A*y(1)*y(5)+Nb*y(5)*y(7)+Nt*(y(5))^2);
yy3 = (-Le*A*(y(1)*y(7))-(Nt/Nb)*( -Pr*(A*y(1)*y(5)+Nb*y(5)*y(7)+Nt*(y(5))^2)));
ysol = [y(2); y(3); yy1;y(5);yy2;y(7);yy3];
end
end how to get second solution from this code.I ploted first solution for different values of alpha.
function Ibrardual
clc
clear all
Nt=0.5; Nb=0.5; Le=2; Pr=1; alpha=-0.2138; s=1; A=1;
%% solution in structure form
%First solution
sol = bvpinit(linspace(0,2,10), [1 0 0 0 0 0 0]);
sol1 = bvp4c(@bvpexam2, @bcexam2, sol);
x1 = sol1.x;
y1=sol.y;
plot(x1,y1(3,:),’b’);
hold on
result=(A)^-1/2*y1(3,1)
%% Here I define residual of boundary conditions
function res = bcexam2(y0, yinf)
res= [y0(1)-s; y0(2)-alpha; y0(4)-1; y0(6)-1;
yinf(2); yinf(4);yinf(6)];
end
%% First order ODEs are define here
function ysol = bvpexam2(x,y)
yy1 = -A*(y(1)*y(3)-(y(2))^2)-y(2);
yy2 = -Pr*(A*y(1)*y(5)+Nb*y(5)*y(7)+Nt*(y(5))^2);
yy3 = (-Le*A*(y(1)*y(7))-(Nt/Nb)*( -Pr*(A*y(1)*y(5)+Nb*y(5)*y(7)+Nt*(y(5))^2)));
ysol = [y(2); y(3); yy1;y(5);yy2;y(7);yy3];
end
end matlab MATLAB Answers — New Questions
about write data to the first sheet of excel
hello, i want wrtie specific data to several sheet of the excel, and i have named each sheet, but i find may new target sheet will added after sheet1, how i can replace sheet1hello, i want wrtie specific data to several sheet of the excel, and i have named each sheet, but i find may new target sheet will added after sheet1, how i can replace sheet1 hello, i want wrtie specific data to several sheet of the excel, and i have named each sheet, but i find may new target sheet will added after sheet1, how i can replace sheet1 xlswrite, write from first sheet MATLAB Answers — New Questions
Error using gbellmf with Matlab
Post Content Post Content gbellmf matlab MATLAB Answers — New Questions
How can.struct data be made available to non-MATLAB users?
I have several scripts which are based on a structure containing multiple fields of data, with nested structures inside. This structure is as is, as it is generated automatically and is used for further processing. However, the dependencies and structure of the work indicated inside this struct are also required for people who do not use MATLAB.
Hence, I’m looking for one of two solutions, which I was unable to find so far.
Can a .struct with nested structs, using a multitude of fieldnames and datalines, be converted to a non-MATLAB format like excel? The command "writetable(struct2table(structname, ‘filename.xlsx’)" works, but does not include the nested data which can be multiple layers deep.
Can the .struct data be saved such that it can be viewed by someone without MATLAB? (e.g. does MATLAB provide something like a ‘viewer’?)I have several scripts which are based on a structure containing multiple fields of data, with nested structures inside. This structure is as is, as it is generated automatically and is used for further processing. However, the dependencies and structure of the work indicated inside this struct are also required for people who do not use MATLAB.
Hence, I’m looking for one of two solutions, which I was unable to find so far.
Can a .struct with nested structs, using a multitude of fieldnames and datalines, be converted to a non-MATLAB format like excel? The command "writetable(struct2table(structname, ‘filename.xlsx’)" works, but does not include the nested data which can be multiple layers deep.
Can the .struct data be saved such that it can be viewed by someone without MATLAB? (e.g. does MATLAB provide something like a ‘viewer’?) I have several scripts which are based on a structure containing multiple fields of data, with nested structures inside. This structure is as is, as it is generated automatically and is used for further processing. However, the dependencies and structure of the work indicated inside this struct are also required for people who do not use MATLAB.
Hence, I’m looking for one of two solutions, which I was unable to find so far.
Can a .struct with nested structs, using a multitude of fieldnames and datalines, be converted to a non-MATLAB format like excel? The command "writetable(struct2table(structname, ‘filename.xlsx’)" works, but does not include the nested data which can be multiple layers deep.
Can the .struct data be saved such that it can be viewed by someone without MATLAB? (e.g. does MATLAB provide something like a ‘viewer’?) .struct, data conversion, struct excel MATLAB Answers — New Questions
Record screen video while running script
Hi!
I would like to record a video of my screen while running a psychtoolbox script (DriftDemo6). Is this possible? I tried with the Mac screen recorder, but it breaks the psychtoolbox script.
Thank you!
LeaHi!
I would like to record a video of my screen while running a psychtoolbox script (DriftDemo6). Is this possible? I tried with the Mac screen recorder, but it breaks the psychtoolbox script.
Thank you!
Lea Hi!
I would like to record a video of my screen while running a psychtoolbox script (DriftDemo6). Is this possible? I tried with the Mac screen recorder, but it breaks the psychtoolbox script.
Thank you!
Lea video, psychtoolbox, screen recording MATLAB Answers — New Questions