## Category: Matlab

### Category Archives: Matlab

## Y double axis required trendlines

x = [1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020];

y1 = [18.1969 15.834 16.5986 3.1579 10.9866 8.2062 8.9229 9.6429 6.4604 14.805 9.1178 0.49 2.9925 8.7875 5.7404 5.365 8.32 13.025 10.9654 3.26 8.975 4.795 0.97 32.3175 11.1025 0.65 9.5425 12.115 9.8975 21.875 16.6925];

y2 = [17.360463 15.30933 12.563672 2.174533 8.407282 5.828774 4.764783 5.524783 3.644908 15.515 7.022406 0.1715 1.168625 4.729125 3.232158 2.149 6.37575 12.0585 7.024658 1.355 5.591 3.088 0.396 25.004125 8.130375 0.2355 5.040375 7.95375 5.477375 18.4155 16.567625];

figure(‘Color’,’w’)

[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);

ylabel(hAx(1),’ACE (knot^2)’) % left y-axis

ylabel(hAx(2),’PDI (knot^3)’) % right y-axis

%grid onx = [1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020];

y1 = [18.1969 15.834 16.5986 3.1579 10.9866 8.2062 8.9229 9.6429 6.4604 14.805 9.1178 0.49 2.9925 8.7875 5.7404 5.365 8.32 13.025 10.9654 3.26 8.975 4.795 0.97 32.3175 11.1025 0.65 9.5425 12.115 9.8975 21.875 16.6925];

y2 = [17.360463 15.30933 12.563672 2.174533 8.407282 5.828774 4.764783 5.524783 3.644908 15.515 7.022406 0.1715 1.168625 4.729125 3.232158 2.149 6.37575 12.0585 7.024658 1.355 5.591 3.088 0.396 25.004125 8.130375 0.2355 5.040375 7.95375 5.477375 18.4155 16.567625];

figure(‘Color’,’w’)

[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);

ylabel(hAx(1),’ACE (knot^2)’) % left y-axis

ylabel(hAx(2),’PDI (knot^3)’) % right y-axis

%grid on x = [1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020];

y1 = [18.1969 15.834 16.5986 3.1579 10.9866 8.2062 8.9229 9.6429 6.4604 14.805 9.1178 0.49 2.9925 8.7875 5.7404 5.365 8.32 13.025 10.9654 3.26 8.975 4.795 0.97 32.3175 11.1025 0.65 9.5425 12.115 9.8975 21.875 16.6925];

y2 = [17.360463 15.30933 12.563672 2.174533 8.407282 5.828774 4.764783 5.524783 3.644908 15.515 7.022406 0.1715 1.168625 4.729125 3.232158 2.149 6.37575 12.0585 7.024658 1.355 5.591 3.088 0.396 25.004125 8.130375 0.2355 5.040375 7.95375 5.477375 18.4155 16.567625];

figure(‘Color’,’w’)

[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);

ylabel(hAx(1),’ACE (knot^2)’) % left y-axis

ylabel(hAx(2),’PDI (knot^3)’) % right y-axis

%grid on trendline, y double axis MATLAB Answers — New Questions

## Is it possible to convert Arduino IDE Code (C++ Code) to MATLAB Code by any means? Or does it have to be done manually?

I’m trying to translate a C++ Code which is used for Soil Moisture Sensor and Raindrop Sensor to a MATLAB Code. I was hoping to convert the C++ Code to a MATLAB Code through faster means since I have no knowledge in C++ Coding. Following is the code.

const int capteur_D = 4;

const int capteur_A = A0;

int val_analogique;

int soilMoistureValue = 0;

int soilmoisturepercent=0;

void setup() {

pinMode(capteur_D, INPUT);

pinMode(capteur_A, INPUT);

Serial.begin(9600); // open serial port, set the baud rate to 9600 bps

}

void loop() {

soilMoistureValue = analogRead(A0); //put Sensor insert into soil

Serial.println(soilMoistureValue);

delay(250);

if(digitalRead(capteur_D) == LOW)

{

Serial.println("Digital value : wet");

delay(10);

}

else

{

Serial.println("Digital value : dry");

delay(10);

}

val_analogique=analogRead(capteur_A);

Serial.print("Analog value : ");

Serial.println(val_analogique);

Serial.println("");

delay(1000);

}I’m trying to translate a C++ Code which is used for Soil Moisture Sensor and Raindrop Sensor to a MATLAB Code. I was hoping to convert the C++ Code to a MATLAB Code through faster means since I have no knowledge in C++ Coding. Following is the code.

const int capteur_D = 4;

const int capteur_A = A0;

int val_analogique;

int soilMoistureValue = 0;

int soilmoisturepercent=0;

void setup() {

pinMode(capteur_D, INPUT);

pinMode(capteur_A, INPUT);

Serial.begin(9600); // open serial port, set the baud rate to 9600 bps

}

void loop() {

soilMoistureValue = analogRead(A0); //put Sensor insert into soil

Serial.println(soilMoistureValue);

delay(250);

if(digitalRead(capteur_D) == LOW)

{

Serial.println("Digital value : wet");

delay(10);

}

else

{

Serial.println("Digital value : dry");

delay(10);

}

val_analogique=analogRead(capteur_A);

Serial.print("Analog value : ");

Serial.println(val_analogique);

Serial.println("");

delay(1000);

} I’m trying to translate a C++ Code which is used for Soil Moisture Sensor and Raindrop Sensor to a MATLAB Code. I was hoping to convert the C++ Code to a MATLAB Code through faster means since I have no knowledge in C++ Coding. Following is the code.

const int capteur_D = 4;

const int capteur_A = A0;

int val_analogique;

int soilMoistureValue = 0;

int soilmoisturepercent=0;

void setup() {

pinMode(capteur_D, INPUT);

pinMode(capteur_A, INPUT);

Serial.begin(9600); // open serial port, set the baud rate to 9600 bps

}

void loop() {

soilMoistureValue = analogRead(A0); //put Sensor insert into soil

Serial.println(soilMoistureValue);

delay(250);

if(digitalRead(capteur_D) == LOW)

{

Serial.println("Digital value : wet");

delay(10);

}

else

{

Serial.println("Digital value : dry");

delay(10);

}

val_analogique=analogRead(capteur_A);

Serial.print("Analog value : ");

Serial.println(val_analogique);

Serial.println("");

delay(1000);

} c++, c++ to matlab MATLAB Answers — New Questions

## Errors while linking unreal engine to matlab

Unreal Engine: 5.1.1

Matlab Release: R2024a

I am trying to make a custom scene in unreal engine, for that I installed Aerospace Toolbox Unreal ENgine Interface, after installing, when I try to opne the editor using

`editor.open()’

I get following message:

I tried to build it through IDE but it gave me the following error:

I need help resolving this issue.Unreal Engine: 5.1.1

Matlab Release: R2024a

I am trying to make a custom scene in unreal engine, for that I installed Aerospace Toolbox Unreal ENgine Interface, after installing, when I try to opne the editor using

`editor.open()’

I get following message:

I tried to build it through IDE but it gave me the following error:

I need help resolving this issue. Unreal Engine: 5.1.1

Matlab Release: R2024a

I am trying to make a custom scene in unreal engine, for that I installed Aerospace Toolbox Unreal ENgine Interface, after installing, when I try to opne the editor using

`editor.open()’

I get following message:

I tried to build it through IDE but it gave me the following error:

I need help resolving this issue. unrealengine MATLAB Answers — New Questions

## Over time reduce an input value linearly with a delay after each decrement, using a Simulink model

I’m trying to create a Simulink model that has an input value that I want to reduce down to zero in a specific time. It must decrease in linear decrements with a delay after each decrement. The initial input value can also be different, but must reduce down to zero in the same time no matter the starting value.

I have tried using a feedback loop to subtract the original value * the time step, but this just results in the output value decreasing to zero immediately.

Are there any specific blocks for this kind fo linear reduction, or is a more complex block system required?

Thanks for the helpI’m trying to create a Simulink model that has an input value that I want to reduce down to zero in a specific time. It must decrease in linear decrements with a delay after each decrement. The initial input value can also be different, but must reduce down to zero in the same time no matter the starting value.

I have tried using a feedback loop to subtract the original value * the time step, but this just results in the output value decreasing to zero immediately.

Are there any specific blocks for this kind fo linear reduction, or is a more complex block system required?

Thanks for the help I’m trying to create a Simulink model that has an input value that I want to reduce down to zero in a specific time. It must decrease in linear decrements with a delay after each decrement. The initial input value can also be different, but must reduce down to zero in the same time no matter the starting value.

I have tried using a feedback loop to subtract the original value * the time step, but this just results in the output value decreasing to zero immediately.

Are there any specific blocks for this kind fo linear reduction, or is a more complex block system required?

Thanks for the help simulink, feedback loop MATLAB Answers — New Questions

## YOLOX – training on tiled images and inference on full-size images

Hello everyone. I am trying to train the YOLOX net for cell detection in brightfield. My original images are 2048×2048. I read on matworks that yolox, being anchor-free, can be trained on tiled images and the inference can be done on full-size images. So what I did was tiliing my images in 4 blocks, 1024×1024 each, then size down everything to 512×512 pixels and do the training. Doing the inference on full-size images gives me 0 precision, as well as scaling down the test set to 1024×1024 pixels, which makes the size of the cells I want to detect the same size as they would be in the preprocessed training set. Is there something I am not grasping due to my scarce experience? thank you to whoever will suggest something. ThanksHello everyone. I am trying to train the YOLOX net for cell detection in brightfield. My original images are 2048×2048. I read on matworks that yolox, being anchor-free, can be trained on tiled images and the inference can be done on full-size images. So what I did was tiliing my images in 4 blocks, 1024×1024 each, then size down everything to 512×512 pixels and do the training. Doing the inference on full-size images gives me 0 precision, as well as scaling down the test set to 1024×1024 pixels, which makes the size of the cells I want to detect the same size as they would be in the preprocessed training set. Is there something I am not grasping due to my scarce experience? thank you to whoever will suggest something. Thanks Hello everyone. I am trying to train the YOLOX net for cell detection in brightfield. My original images are 2048×2048. I read on matworks that yolox, being anchor-free, can be trained on tiled images and the inference can be done on full-size images. So what I did was tiliing my images in 4 blocks, 1024×1024 each, then size down everything to 512×512 pixels and do the training. Doing the inference on full-size images gives me 0 precision, as well as scaling down the test set to 1024×1024 pixels, which makes the size of the cells I want to detect the same size as they would be in the preprocessed training set. Is there something I am not grasping due to my scarce experience? thank you to whoever will suggest something. Thanks yolo, deep learning, detection, machine learning, image processing, computer vision MATLAB Answers — New Questions

## error when using lsqnonlin to function containing fzero function

I want to use lsqnonlin analysis to fit a model to two sets of data and obtain values of 4 variables. The function i created contains fzero function which only allows scalar values and i finally got the error ‘operands to the || and && operators ust be convertible to logical scalar values. ‘ So is there any other method that can replace lsqnonlin to solve my problem? Or any corrections, changes to be made in my code to solve this with lsqnonlin? Thanks! Here’s my function file and code.

function Result = myfunc1(a,p,G,m,fraction)

totalconcentration = 0.0000291;

n = 2;

K = exp(-((G + m * fraction)./(8.314*298)));

g_lb = 0;

g_ub = 0.9999;

g =[g_lb g_ub];

monomerconcentration = fzero(@denaturationfun,g);

function y = denaturationfun(x)

y = a.^(-1).*(((a.*x).^(n+1)).*(n.*a.*x-n-1)/((a.*x-1).^2)+a.*x/((a.*x-1).^2))-a.^(n-1).*((x^(n+1)).*(n.*x-n-1)/((x-1).^2))-K.*totalconcentration;

end

Result = p * (1- (monomerconcentration / ( K * totalconcentration )));

end

clc;

clear;

close all;

fractiondata = [0.1505 0.1546 0.1587 0.1628 0.1668 0.1708 0.1748 0.1787 0.1825 0.1864 0.1902 0.194 0.1977 0.2014 0.205 0.2087 0.2123];

DegreeofAggdata = [1 0.9087 0.8658 0.83453 0.79569 0.67979 0.62031 0.53043 0.39722 0.25888 0.15171 0.04759 0.00109 3.20E-04 0.00144 7.77E-04 0];

fun = @(x)DegreeofAggdata – myfunc1(x(1),x(2),x(3),x(4),fractiondata);

x0 = [0.01,0.9,-50000,100000];

lb = [0.00001,0.9,-100000,20000];

ub = [1,1.1,-10000,130000];

x = lsqnonlin(fun,x0,lb,ub);I want to use lsqnonlin analysis to fit a model to two sets of data and obtain values of 4 variables. The function i created contains fzero function which only allows scalar values and i finally got the error ‘operands to the || and && operators ust be convertible to logical scalar values. ‘ So is there any other method that can replace lsqnonlin to solve my problem? Or any corrections, changes to be made in my code to solve this with lsqnonlin? Thanks! Here’s my function file and code.

function Result = myfunc1(a,p,G,m,fraction)

totalconcentration = 0.0000291;

n = 2;

K = exp(-((G + m * fraction)./(8.314*298)));

g_lb = 0;

g_ub = 0.9999;

g =[g_lb g_ub];

monomerconcentration = fzero(@denaturationfun,g);

function y = denaturationfun(x)

y = a.^(-1).*(((a.*x).^(n+1)).*(n.*a.*x-n-1)/((a.*x-1).^2)+a.*x/((a.*x-1).^2))-a.^(n-1).*((x^(n+1)).*(n.*x-n-1)/((x-1).^2))-K.*totalconcentration;

end

Result = p * (1- (monomerconcentration / ( K * totalconcentration )));

end

clc;

clear;

close all;

fractiondata = [0.1505 0.1546 0.1587 0.1628 0.1668 0.1708 0.1748 0.1787 0.1825 0.1864 0.1902 0.194 0.1977 0.2014 0.205 0.2087 0.2123];

DegreeofAggdata = [1 0.9087 0.8658 0.83453 0.79569 0.67979 0.62031 0.53043 0.39722 0.25888 0.15171 0.04759 0.00109 3.20E-04 0.00144 7.77E-04 0];

fun = @(x)DegreeofAggdata – myfunc1(x(1),x(2),x(3),x(4),fractiondata);

x0 = [0.01,0.9,-50000,100000];

lb = [0.00001,0.9,-100000,20000];

ub = [1,1.1,-10000,130000];

x = lsqnonlin(fun,x0,lb,ub); I want to use lsqnonlin analysis to fit a model to two sets of data and obtain values of 4 variables. The function i created contains fzero function which only allows scalar values and i finally got the error ‘operands to the || and && operators ust be convertible to logical scalar values. ‘ So is there any other method that can replace lsqnonlin to solve my problem? Or any corrections, changes to be made in my code to solve this with lsqnonlin? Thanks! Here’s my function file and code.

function Result = myfunc1(a,p,G,m,fraction)

totalconcentration = 0.0000291;

n = 2;

K = exp(-((G + m * fraction)./(8.314*298)));

g_lb = 0;

g_ub = 0.9999;

g =[g_lb g_ub];

monomerconcentration = fzero(@denaturationfun,g);

function y = denaturationfun(x)

y = a.^(-1).*(((a.*x).^(n+1)).*(n.*a.*x-n-1)/((a.*x-1).^2)+a.*x/((a.*x-1).^2))-a.^(n-1).*((x^(n+1)).*(n.*x-n-1)/((x-1).^2))-K.*totalconcentration;

end

Result = p * (1- (monomerconcentration / ( K * totalconcentration )));

end

clc;

clear;

close all;

fractiondata = [0.1505 0.1546 0.1587 0.1628 0.1668 0.1708 0.1748 0.1787 0.1825 0.1864 0.1902 0.194 0.1977 0.2014 0.205 0.2087 0.2123];

DegreeofAggdata = [1 0.9087 0.8658 0.83453 0.79569 0.67979 0.62031 0.53043 0.39722 0.25888 0.15171 0.04759 0.00109 3.20E-04 0.00144 7.77E-04 0];

fun = @(x)DegreeofAggdata – myfunc1(x(1),x(2),x(3),x(4),fractiondata);

x0 = [0.01,0.9,-50000,100000];

lb = [0.00001,0.9,-100000,20000];

ub = [1,1.1,-10000,130000];

x = lsqnonlin(fun,x0,lb,ub); matlab, lsqnonlin, fzero, fit model MATLAB Answers — New Questions

## Why does findobj behave different in windows than in unix systems?

Hello,

I am facing something rather curious, I am noticing a behaviour different on Matlab function findobj in Windows(10/11) or Unix ( ubuntu 22).

My issue roots to the search of figures by name, in windows I use the function like this

figHandle = findobj(groot,’Name’,figName);

so providing the figName finds the figure as expected, but running same command under Matlab unix version it returns empty figHandle. I use the Matlab unix version in my CI environment where I found the issue.

Does it rely on lower OS functions that do not behave the same? Can I overcome this issue?

Thanks in advance,

RegardsHello,

I am facing something rather curious, I am noticing a behaviour different on Matlab function findobj in Windows(10/11) or Unix ( ubuntu 22).

My issue roots to the search of figures by name, in windows I use the function like this

figHandle = findobj(groot,’Name’,figName);

so providing the figName finds the figure as expected, but running same command under Matlab unix version it returns empty figHandle. I use the Matlab unix version in my CI environment where I found the issue.

Does it rely on lower OS functions that do not behave the same? Can I overcome this issue?

Thanks in advance,

Regards Hello,

I am facing something rather curious, I am noticing a behaviour different on Matlab function findobj in Windows(10/11) or Unix ( ubuntu 22).

My issue roots to the search of figures by name, in windows I use the function like this

figHandle = findobj(groot,’Name’,figName);

so providing the figName finds the figure as expected, but running same command under Matlab unix version it returns empty figHandle. I use the Matlab unix version in my CI environment where I found the issue.

Does it rely on lower OS functions that do not behave the same? Can I overcome this issue?

Thanks in advance,

Regards findobj MATLAB Answers — New Questions

## How to use LSTM to solve seq2seq problem in MATLAB?

I’m struggling with a seq2seq problem. That is: input 200 past values and use LSTM network to predict next 10 values at one time(winthout using closed loop forecasting).And I tried writing the code as shown below. But it will report an error: Invalid training data. For regression tasks, responses must be a vector, a matrix, or a 4-D array of real numeric responses. Responses must not contain NaNs.

inputSize = 5; % Number of input features

numTimeSteps = 200; % Number of time steps

numSamples = 100; % Number of samples

% Create random input data, a cell array of size [5, 200]

X = cell(numSamples, 1);

for i = 1:numSamples

X{i} = rand(inputSize, numTimeSteps);

end

outputSize = 1; % Number of output features for each time step

outputTimeSteps = 10; % Number of output time steps

numSamples = 100; % Number of samples

% Create random output data, a cell array of size [1, 10]

Y = cell(numSamples, 1);

for i = 1:numSamples

Y{i} = rand(outputSize, outputTimeSteps);

end

numHiddenUnits1 = 128; % Number of hidden units in the first LSTM layer

numHiddenUnits2 = 64; % Number of hidden units in the second LSTM layer

outputSize = 1; % Number of output features

layers = [

sequenceInputLayer(inputSize) % Input layer, number of input features is 5

lstmLayer(numHiddenUnits1, ‘OutputMode’, ‘last’) % First LSTM layer, outputs the last time step

fullyConnectedLayer(numHiddenUnits2) % Fully connected layer, transforms the input dimensions for the second LSTM layer

functionLayer(@(X) repmat(X, [1, outputTimeSteps]), ‘Name’, ‘replicate10’) % Expand the output of the last time step to 10 time steps

lstmLayer(numHiddenUnits2, ‘OutputMode’, ‘sequence’) % Second LSTM layer, outputs a sequence of 10 time steps

fullyConnectedLayer(outputSize) % Fully connected layer, number of output features is 1

regressionLayer]; % Regression layer, used for regression tasks

% Training options

options = trainingOptions(‘adam’, …

‘MaxEpochs’, 50, …

‘MiniBatchSize’, 32, …

‘Shuffle’, ‘every-epoch’, …

‘Verbose’, false);

% Train the network

net = trainNetwork(X, Y, layers, options);

Now I have two questions:

(1) What data format should be used for the input and output of the model during training? Cell arrays or 3D arrays?

(2) How to control the time expansion steps of the input and output for each layer (input layer, LSTM layer, fully connected layer) in an LSTM network?I’m struggling with a seq2seq problem. That is: input 200 past values and use LSTM network to predict next 10 values at one time(winthout using closed loop forecasting).And I tried writing the code as shown below. But it will report an error: Invalid training data. For regression tasks, responses must be a vector, a matrix, or a 4-D array of real numeric responses. Responses must not contain NaNs.

inputSize = 5; % Number of input features

numTimeSteps = 200; % Number of time steps

numSamples = 100; % Number of samples

% Create random input data, a cell array of size [5, 200]

X = cell(numSamples, 1);

for i = 1:numSamples

X{i} = rand(inputSize, numTimeSteps);

end

outputSize = 1; % Number of output features for each time step

outputTimeSteps = 10; % Number of output time steps

numSamples = 100; % Number of samples

% Create random output data, a cell array of size [1, 10]

Y = cell(numSamples, 1);

for i = 1:numSamples

Y{i} = rand(outputSize, outputTimeSteps);

end

numHiddenUnits1 = 128; % Number of hidden units in the first LSTM layer

numHiddenUnits2 = 64; % Number of hidden units in the second LSTM layer

outputSize = 1; % Number of output features

layers = [

sequenceInputLayer(inputSize) % Input layer, number of input features is 5

lstmLayer(numHiddenUnits1, ‘OutputMode’, ‘last’) % First LSTM layer, outputs the last time step

fullyConnectedLayer(numHiddenUnits2) % Fully connected layer, transforms the input dimensions for the second LSTM layer

functionLayer(@(X) repmat(X, [1, outputTimeSteps]), ‘Name’, ‘replicate10’) % Expand the output of the last time step to 10 time steps

lstmLayer(numHiddenUnits2, ‘OutputMode’, ‘sequence’) % Second LSTM layer, outputs a sequence of 10 time steps

fullyConnectedLayer(outputSize) % Fully connected layer, number of output features is 1

regressionLayer]; % Regression layer, used for regression tasks

% Training options

options = trainingOptions(‘adam’, …

‘MaxEpochs’, 50, …

‘MiniBatchSize’, 32, …

‘Shuffle’, ‘every-epoch’, …

‘Verbose’, false);

% Train the network

net = trainNetwork(X, Y, layers, options);

Now I have two questions:

(1) What data format should be used for the input and output of the model during training? Cell arrays or 3D arrays?

(2) How to control the time expansion steps of the input and output for each layer (input layer, LSTM layer, fully connected layer) in an LSTM network? I’m struggling with a seq2seq problem. That is: input 200 past values and use LSTM network to predict next 10 values at one time(winthout using closed loop forecasting).And I tried writing the code as shown below. But it will report an error: Invalid training data. For regression tasks, responses must be a vector, a matrix, or a 4-D array of real numeric responses. Responses must not contain NaNs.

inputSize = 5; % Number of input features

numTimeSteps = 200; % Number of time steps

numSamples = 100; % Number of samples

% Create random input data, a cell array of size [5, 200]

X = cell(numSamples, 1);

for i = 1:numSamples

X{i} = rand(inputSize, numTimeSteps);

end

outputSize = 1; % Number of output features for each time step

outputTimeSteps = 10; % Number of output time steps

numSamples = 100; % Number of samples

% Create random output data, a cell array of size [1, 10]

Y = cell(numSamples, 1);

for i = 1:numSamples

Y{i} = rand(outputSize, outputTimeSteps);

end

numHiddenUnits1 = 128; % Number of hidden units in the first LSTM layer

numHiddenUnits2 = 64; % Number of hidden units in the second LSTM layer

outputSize = 1; % Number of output features

layers = [

sequenceInputLayer(inputSize) % Input layer, number of input features is 5

lstmLayer(numHiddenUnits1, ‘OutputMode’, ‘last’) % First LSTM layer, outputs the last time step

fullyConnectedLayer(numHiddenUnits2) % Fully connected layer, transforms the input dimensions for the second LSTM layer

functionLayer(@(X) repmat(X, [1, outputTimeSteps]), ‘Name’, ‘replicate10’) % Expand the output of the last time step to 10 time steps

lstmLayer(numHiddenUnits2, ‘OutputMode’, ‘sequence’) % Second LSTM layer, outputs a sequence of 10 time steps

fullyConnectedLayer(outputSize) % Fully connected layer, number of output features is 1

regressionLayer]; % Regression layer, used for regression tasks

% Training options

options = trainingOptions(‘adam’, …

‘MaxEpochs’, 50, …

‘MiniBatchSize’, 32, …

‘Shuffle’, ‘every-epoch’, …

‘Verbose’, false);

% Train the network

net = trainNetwork(X, Y, layers, options);

Now I have two questions:

(1) What data format should be used for the input and output of the model during training? Cell arrays or 3D arrays?

(2) How to control the time expansion steps of the input and output for each layer (input layer, LSTM layer, fully connected layer) in an LSTM network? lstm, seq2seq, multi step MATLAB Answers — New Questions

## Newton method for solving a nonlinear system of equations!

Hello,

I am trying to write a function that solves a non linear system of equations. In my exercise I have 2,3 and 4 dimensional equation system. I am not allowed to use fsolve function. I also have a function called "Score4" which is suppose to calculate the score of my function ( should be around 1 if the code that I wrote is correct).

Below you will find the score and the code that I wrote.

Thank you in advance for your time.

function [score,error,details] = Score4()

%% Parameter

% 2 dimensional equation system

A{1} = @(x)[4*cos(x(1)),2*cos(x(1)+x(2));

5*sin(x(1)),1*sin(x(1)+x(2))];

x0{1} = [0,0]’;

y{1} = [2,3]’;

y0{1} = [-1,1]’;

% 3 dimensional equation system

A{2} = @(x)[1,0,0;0,cos(x(1)),-sin(x(2));0,sin(x(2))^2,cos(x(1))];

x0{2} = [0;0];

y0{2} = [1;2;3];

y{2} = [1;0;1];

% 4 dimensional transformation matrix with 5d input

A{3} = @(x)[cos(x(1)),sin(x(1)),0,-x(3);

-sin(x(1))*cos(x(4)),cos(x(1))*cos(x(4)),sin(x(4))*sin(x(5)),-x(2)*sin(x(4))*cos(x(5));

sin(x(4))*sin(x(1)),-cos(x(1))*sin(x(4)),cos(x(4))*sin(x(5)),-x(2)*cos(x(4))*cos(x(5));

0,0,0,1];

x0{3} = [0;0;0;0;0];

y0{3} = [1;3;2;1];

y{3} = [1;2;-1;1];

%% Score Berechnung

score = 0;

error = ”;

details = struct();

try

% Iteration ueber testcases

for i = 1:3

% Aufstellen des nullstellenproblems

RootProblem = @(z) A{i}(z)*y0{i}-y{i};

T = 0;

% Mitteln ueber Zeit

timer = tic();

for j = 1:10

x = nlinSolve(RootProblem,x0{i});

end

T = toc(timer)/10;

output = A{i}(x)*y0{i}-y{i};

Err = norm(output);

Sc = (Err+0.01)*(T+0.5);

score = score+Sc;

details.([‘time’,num2str(i)]) = T;

details.([‘error’,num2str(i)]) = Err;

end

score = 0.017 / score;

catch err

score = 0;

error = err.message;

end

end

To solve this problem I was thinking to use Newton method but I am having a lot of problems. Can someone give me some suggestions how to improve my code and what am I doing wrong. My code is as follows:

function x = nlinSolve (g,x0)

select = @(g,r,c) g(r,c);

G1 = @(x)select(g(x), 1, 1); % selecting the first row of g(x)

G2 = @(x)select(g(x), 2, 1); % selecting the second row

G3 = @(x)select(g(x), 3, 1);

G4 = @(x)select(g(x), 4, 1);

G5 = @(x)select(g(x), 5, 1);

x = x0; % x0 initial guess which is given in the score function

for m=1:10

%calculating Jacobian

for k=1:numel(x)

for n =1: numel(x)

Jakobian(k,n)= Derivative(eval([‘G’,num2str(k)]),x,x(n),n);

end

end

x = x-inv(Jakobian)*g(x); % Newton formula to find roots

end

end

function J = Derivative(G,x,xm,m)

% the funciton that calculates the derivative using numerical method

e = 0.0001;

x1=x;

x2=x;

x1(m) = xm;

x2(m) = xm+e;

J = (G(x2)-G(x1))/e;

end

Now this code is clearly not working, I am messing up something. Also the score should be around 1 at the end.

If anyone can help me that would be more than appritiated.Hello,

I am trying to write a function that solves a non linear system of equations. In my exercise I have 2,3 and 4 dimensional equation system. I am not allowed to use fsolve function. I also have a function called "Score4" which is suppose to calculate the score of my function ( should be around 1 if the code that I wrote is correct).

Below you will find the score and the code that I wrote.

Thank you in advance for your time.

function [score,error,details] = Score4()

%% Parameter

% 2 dimensional equation system

A{1} = @(x)[4*cos(x(1)),2*cos(x(1)+x(2));

5*sin(x(1)),1*sin(x(1)+x(2))];

x0{1} = [0,0]’;

y{1} = [2,3]’;

y0{1} = [-1,1]’;

% 3 dimensional equation system

A{2} = @(x)[1,0,0;0,cos(x(1)),-sin(x(2));0,sin(x(2))^2,cos(x(1))];

x0{2} = [0;0];

y0{2} = [1;2;3];

y{2} = [1;0;1];

% 4 dimensional transformation matrix with 5d input

A{3} = @(x)[cos(x(1)),sin(x(1)),0,-x(3);

-sin(x(1))*cos(x(4)),cos(x(1))*cos(x(4)),sin(x(4))*sin(x(5)),-x(2)*sin(x(4))*cos(x(5));

sin(x(4))*sin(x(1)),-cos(x(1))*sin(x(4)),cos(x(4))*sin(x(5)),-x(2)*cos(x(4))*cos(x(5));

0,0,0,1];

x0{3} = [0;0;0;0;0];

y0{3} = [1;3;2;1];

y{3} = [1;2;-1;1];

%% Score Berechnung

score = 0;

error = ”;

details = struct();

try

% Iteration ueber testcases

for i = 1:3

% Aufstellen des nullstellenproblems

RootProblem = @(z) A{i}(z)*y0{i}-y{i};

T = 0;

% Mitteln ueber Zeit

timer = tic();

for j = 1:10

x = nlinSolve(RootProblem,x0{i});

end

T = toc(timer)/10;

output = A{i}(x)*y0{i}-y{i};

Err = norm(output);

Sc = (Err+0.01)*(T+0.5);

score = score+Sc;

details.([‘time’,num2str(i)]) = T;

details.([‘error’,num2str(i)]) = Err;

end

score = 0.017 / score;

catch err

score = 0;

error = err.message;

end

end

To solve this problem I was thinking to use Newton method but I am having a lot of problems. Can someone give me some suggestions how to improve my code and what am I doing wrong. My code is as follows:

function x = nlinSolve (g,x0)

select = @(g,r,c) g(r,c);

G1 = @(x)select(g(x), 1, 1); % selecting the first row of g(x)

G2 = @(x)select(g(x), 2, 1); % selecting the second row

G3 = @(x)select(g(x), 3, 1);

G4 = @(x)select(g(x), 4, 1);

G5 = @(x)select(g(x), 5, 1);

x = x0; % x0 initial guess which is given in the score function

for m=1:10

%calculating Jacobian

for k=1:numel(x)

for n =1: numel(x)

Jakobian(k,n)= Derivative(eval([‘G’,num2str(k)]),x,x(n),n);

end

end

x = x-inv(Jakobian)*g(x); % Newton formula to find roots

end

end

function J = Derivative(G,x,xm,m)

% the funciton that calculates the derivative using numerical method

e = 0.0001;

x1=x;

x2=x;

x1(m) = xm;

x2(m) = xm+e;

J = (G(x2)-G(x1))/e;

end

Now this code is clearly not working, I am messing up something. Also the score should be around 1 at the end.

If anyone can help me that would be more than appritiated. Hello,

I am trying to write a function that solves a non linear system of equations. In my exercise I have 2,3 and 4 dimensional equation system. I am not allowed to use fsolve function. I also have a function called "Score4" which is suppose to calculate the score of my function ( should be around 1 if the code that I wrote is correct).

Below you will find the score and the code that I wrote.

Thank you in advance for your time.

function [score,error,details] = Score4()

%% Parameter

% 2 dimensional equation system

A{1} = @(x)[4*cos(x(1)),2*cos(x(1)+x(2));

5*sin(x(1)),1*sin(x(1)+x(2))];

x0{1} = [0,0]’;

y{1} = [2,3]’;

y0{1} = [-1,1]’;

% 3 dimensional equation system

A{2} = @(x)[1,0,0;0,cos(x(1)),-sin(x(2));0,sin(x(2))^2,cos(x(1))];

x0{2} = [0;0];

y0{2} = [1;2;3];

y{2} = [1;0;1];

% 4 dimensional transformation matrix with 5d input

A{3} = @(x)[cos(x(1)),sin(x(1)),0,-x(3);

-sin(x(1))*cos(x(4)),cos(x(1))*cos(x(4)),sin(x(4))*sin(x(5)),-x(2)*sin(x(4))*cos(x(5));

sin(x(4))*sin(x(1)),-cos(x(1))*sin(x(4)),cos(x(4))*sin(x(5)),-x(2)*cos(x(4))*cos(x(5));

0,0,0,1];

x0{3} = [0;0;0;0;0];

y0{3} = [1;3;2;1];

y{3} = [1;2;-1;1];

%% Score Berechnung

score = 0;

error = ”;

details = struct();

try

% Iteration ueber testcases

for i = 1:3

% Aufstellen des nullstellenproblems

RootProblem = @(z) A{i}(z)*y0{i}-y{i};

T = 0;

% Mitteln ueber Zeit

timer = tic();

for j = 1:10

x = nlinSolve(RootProblem,x0{i});

end

T = toc(timer)/10;

output = A{i}(x)*y0{i}-y{i};

Err = norm(output);

Sc = (Err+0.01)*(T+0.5);

score = score+Sc;

details.([‘time’,num2str(i)]) = T;

details.([‘error’,num2str(i)]) = Err;

end

score = 0.017 / score;

catch err

score = 0;

error = err.message;

end

end

To solve this problem I was thinking to use Newton method but I am having a lot of problems. Can someone give me some suggestions how to improve my code and what am I doing wrong. My code is as follows:

function x = nlinSolve (g,x0)

select = @(g,r,c) g(r,c);

G1 = @(x)select(g(x), 1, 1); % selecting the first row of g(x)

G2 = @(x)select(g(x), 2, 1); % selecting the second row

G3 = @(x)select(g(x), 3, 1);

G4 = @(x)select(g(x), 4, 1);

G5 = @(x)select(g(x), 5, 1);

x = x0; % x0 initial guess which is given in the score function

for m=1:10

%calculating Jacobian

for k=1:numel(x)

for n =1: numel(x)

Jakobian(k,n)= Derivative(eval([‘G’,num2str(k)]),x,x(n),n);

end

end

x = x-inv(Jakobian)*g(x); % Newton formula to find roots

end

end

function J = Derivative(G,x,xm,m)

% the funciton that calculates the derivative using numerical method

e = 0.0001;

x1=x;

x2=x;

x1(m) = xm;

x2(m) = xm+e;

J = (G(x2)-G(x1))/e;

end

Now this code is clearly not working, I am messing up something. Also the score should be around 1 at the end.

If anyone can help me that would be more than appritiated. newton method, nonlinear system of equations, matlab MATLAB Answers — New Questions

## I can not use the command‘plot’，what should I do？

error information:

错误使用 plot

查找类 matlab.graphics.chart.primitive.Line 时出错。

But I cannot find the’primitive’ floder. What should I do if I want to use ‘plot’ normally？

ps：The executed program is as follows, which is a simple piece of code.

x = linspace(0,2*pi);

y1 = sin(x);

y2 = cos(x);

plot(x,y1,x,y2)

title(‘y1=sin(x), y2=cos(x)’)

xlabel(‘X(m)’)

ylabel(‘Y(m)’)error information:

错误使用 plot

查找类 matlab.graphics.chart.primitive.Line 时出错。

But I cannot find the’primitive’ floder. What should I do if I want to use ‘plot’ normally？

ps：The executed program is as follows, which is a simple piece of code.

x = linspace(0,2*pi);

y1 = sin(x);

y2 = cos(x);

plot(x,y1,x,y2)

title(‘y1=sin(x), y2=cos(x)’)

xlabel(‘X(m)’)

ylabel(‘Y(m)’) error information:

错误使用 plot

查找类 matlab.graphics.chart.primitive.Line 时出错。

But I cannot find the’primitive’ floder. What should I do if I want to use ‘plot’ normally？

ps：The executed program is as follows, which is a simple piece of code.

x = linspace(0,2*pi);

y1 = sin(x);

y2 = cos(x);

plot(x,y1,x,y2)

title(‘y1=sin(x), y2=cos(x)’)

xlabel(‘X(m)’)

ylabel(‘Y(m)’) plot MATLAB Answers — New Questions

## How do I check if a subsystem handle is for a stateflow chart

Hello,

I am trying to write a script that parses my model identifying all subsystems for subsequent processing/modifications via the script.

However, when I have a handle that actually corresponds to a stateflow chart I need to switch to using the stateflow API but how can I easily check if a subsystem handle is a stateflow chart?Hello,

I am trying to write a script that parses my model identifying all subsystems for subsequent processing/modifications via the script.

However, when I have a handle that actually corresponds to a stateflow chart I need to switch to using the stateflow API but how can I easily check if a subsystem handle is a stateflow chart? Hello,

I am trying to write a script that parses my model identifying all subsystems for subsequent processing/modifications via the script.

However, when I have a handle that actually corresponds to a stateflow chart I need to switch to using the stateflow API but how can I easily check if a subsystem handle is a stateflow chart? subsystem handle MATLAB Answers — New Questions

## Use only the schema without using pre-trained weights

I want to use RESnet-50 without using pre-trained weights by deep learning Toolbox,how can i do?I want to use RESnet-50 without using pre-trained weights by deep learning Toolbox,how can i do? I want to use RESnet-50 without using pre-trained weights by deep learning Toolbox,how can i do? deep learning, deep learning toolbox MATLAB Answers — New Questions

## environment of a ROV in simscape

i exported my rov model from solidwork as you can see in the picture bilow i added a transforme sensor and a scoop so that i can see my rov under the influence of gravity but now i want to see my rov in the simulation move in the 3 axes x y z when i searched in internet it says that i need to creet and environment for my rov but i dont know how to do it would you please help mei exported my rov model from solidwork as you can see in the picture bilow i added a transforme sensor and a scoop so that i can see my rov under the influence of gravity but now i want to see my rov in the simulation move in the 3 axes x y z when i searched in internet it says that i need to creet and environment for my rov but i dont know how to do it would you please help me i exported my rov model from solidwork as you can see in the picture bilow i added a transforme sensor and a scoop so that i can see my rov under the influence of gravity but now i want to see my rov in the simulation move in the 3 axes x y z when i searched in internet it says that i need to creet and environment for my rov but i dont know how to do it would you please help me simscape MATLAB Answers — New Questions

## 2D MIMO virtual antenna array with different tx and rx antennas

Hi All!

I am trying to build up an antenna object, which consists of 3 TX and 4 RX antennas, which would eventually end up as a 2D 12 element virtual antenna array. The TX and RX antennas would have different design, therefore I need to import different characteristics for TX and RX.

My plan is to check and optimize the virtual antenna array pattern, however, I cannot combine the TX and RX array as a virtual array.

I can also combine the TX and RX patterns, but as far as I know, that is just the magnitude, and not the phase. I want to make sure, that the TX and RX phase pattern is properly taken into account.

Here is the code I have so far (the antennas are not real, just a simulated patch and vivaldi antenna data, I won’t even use vivaldi antenna in the future). All the filepath and sensor positions info is deleted.

Many thanks in advance!

clear all;

clc;

%% Parameters

Freq = 62e9;

c = 3e8;

Lambda = c/Freq;

Phi = [0:2:360];

Theta = [0:2:180];

%% Create TX array

% Add Patch element

PatchMagPat = readmatrix(‘VVV.csv’);

PatchPhasePat = readmatrix(‘WWW.csv’);

PatchMag = reshape(PatchMagPat(:, 3), length(Phi), length(Theta))’;

PatchPhase = reshape(PatchPhasePat(:, 3), length(Phi), length(Theta))’;

AntElem_Patch = phased.CustomAntennaElement(‘PatternCoordinateSystem’,’phi-theta’,’PhiAngles’,Phi,’ThetaAngles’,Theta, …

‘MagnitudePattern’,PatchMag,’PhasePattern’,PatchPhase);

txarray = phased.ConformalArray(‘Element’,AntElem_Patch,…

‘ElementPosition’,’???’);

txradiator = phased.Radiator(‘Sensor’,txarray,’OperatingFrequency’,Freq,…

‘PropagationSpeed’,c);

%% Create RX array

% Add Vivaldi element

VivaldiMagPat = readmatrix(‘XXX.csv’);

VivaldiPhasePat = readmatrix(‘YYY.csv’);

VivaldiMag = reshape(VivaldiMagPat(:, 3), length(Phi), length(Theta))’;

VivaldiPhase = reshape(VivaldiPhasePat(:, 3), length(Phi), length(Theta))’;

AntElem_Vivaldi = phased.CustomAntennaElement(‘PatternCoordinateSystem’,’phi-theta’,’PhiAngles’,Phi,’ThetaAngles’,Theta, …

‘MagnitudePattern’,VivaldiMag,’PhasePattern’,VivaldiPhase);

rxarray = phased.ConformalArray(‘Element’,AntElem_Patch,…

‘ElementPosition’,’???’);

rxcollector = phased.Collector(‘Sensor’,rxarray,’OperatingFrequency’,Freq,…

‘PropagationSpeed’,c);Hi All!

I am trying to build up an antenna object, which consists of 3 TX and 4 RX antennas, which would eventually end up as a 2D 12 element virtual antenna array. The TX and RX antennas would have different design, therefore I need to import different characteristics for TX and RX.

My plan is to check and optimize the virtual antenna array pattern, however, I cannot combine the TX and RX array as a virtual array.

I can also combine the TX and RX patterns, but as far as I know, that is just the magnitude, and not the phase. I want to make sure, that the TX and RX phase pattern is properly taken into account.

Here is the code I have so far (the antennas are not real, just a simulated patch and vivaldi antenna data, I won’t even use vivaldi antenna in the future). All the filepath and sensor positions info is deleted.

Many thanks in advance!

clear all;

clc;

%% Parameters

Freq = 62e9;

c = 3e8;

Lambda = c/Freq;

Phi = [0:2:360];

Theta = [0:2:180];

%% Create TX array

% Add Patch element

PatchMagPat = readmatrix(‘VVV.csv’);

PatchPhasePat = readmatrix(‘WWW.csv’);

PatchMag = reshape(PatchMagPat(:, 3), length(Phi), length(Theta))’;

PatchPhase = reshape(PatchPhasePat(:, 3), length(Phi), length(Theta))’;

AntElem_Patch = phased.CustomAntennaElement(‘PatternCoordinateSystem’,’phi-theta’,’PhiAngles’,Phi,’ThetaAngles’,Theta, …

‘MagnitudePattern’,PatchMag,’PhasePattern’,PatchPhase);

txarray = phased.ConformalArray(‘Element’,AntElem_Patch,…

‘ElementPosition’,’???’);

txradiator = phased.Radiator(‘Sensor’,txarray,’OperatingFrequency’,Freq,…

‘PropagationSpeed’,c);

%% Create RX array

% Add Vivaldi element

VivaldiMagPat = readmatrix(‘XXX.csv’);

VivaldiPhasePat = readmatrix(‘YYY.csv’);

VivaldiMag = reshape(VivaldiMagPat(:, 3), length(Phi), length(Theta))’;

VivaldiPhase = reshape(VivaldiPhasePat(:, 3), length(Phi), length(Theta))’;

AntElem_Vivaldi = phased.CustomAntennaElement(‘PatternCoordinateSystem’,’phi-theta’,’PhiAngles’,Phi,’ThetaAngles’,Theta, …

‘MagnitudePattern’,VivaldiMag,’PhasePattern’,VivaldiPhase);

rxarray = phased.ConformalArray(‘Element’,AntElem_Patch,…

‘ElementPosition’,’???’);

rxcollector = phased.Collector(‘Sensor’,rxarray,’OperatingFrequency’,Freq,…

‘PropagationSpeed’,c); Hi All!

I am trying to build up an antenna object, which consists of 3 TX and 4 RX antennas, which would eventually end up as a 2D 12 element virtual antenna array. The TX and RX antennas would have different design, therefore I need to import different characteristics for TX and RX.

My plan is to check and optimize the virtual antenna array pattern, however, I cannot combine the TX and RX array as a virtual array.

I can also combine the TX and RX patterns, but as far as I know, that is just the magnitude, and not the phase. I want to make sure, that the TX and RX phase pattern is properly taken into account.

Here is the code I have so far (the antennas are not real, just a simulated patch and vivaldi antenna data, I won’t even use vivaldi antenna in the future). All the filepath and sensor positions info is deleted.

Many thanks in advance!

clear all;

clc;

%% Parameters

Freq = 62e9;

c = 3e8;

Lambda = c/Freq;

Phi = [0:2:360];

Theta = [0:2:180];

%% Create TX array

% Add Patch element

PatchMagPat = readmatrix(‘VVV.csv’);

PatchPhasePat = readmatrix(‘WWW.csv’);

PatchMag = reshape(PatchMagPat(:, 3), length(Phi), length(Theta))’;

PatchPhase = reshape(PatchPhasePat(:, 3), length(Phi), length(Theta))’;

AntElem_Patch = phased.CustomAntennaElement(‘PatternCoordinateSystem’,’phi-theta’,’PhiAngles’,Phi,’ThetaAngles’,Theta, …

‘MagnitudePattern’,PatchMag,’PhasePattern’,PatchPhase);

txarray = phased.ConformalArray(‘Element’,AntElem_Patch,…

‘ElementPosition’,’???’);

txradiator = phased.Radiator(‘Sensor’,txarray,’OperatingFrequency’,Freq,…

‘PropagationSpeed’,c);

%% Create RX array

% Add Vivaldi element

VivaldiMagPat = readmatrix(‘XXX.csv’);

VivaldiPhasePat = readmatrix(‘YYY.csv’);

VivaldiMag = reshape(VivaldiMagPat(:, 3), length(Phi), length(Theta))’;

VivaldiPhase = reshape(VivaldiPhasePat(:, 3), length(Phi), length(Theta))’;

AntElem_Vivaldi = phased.CustomAntennaElement(‘PatternCoordinateSystem’,’phi-theta’,’PhiAngles’,Phi,’ThetaAngles’,Theta, …

‘MagnitudePattern’,VivaldiMag,’PhasePattern’,VivaldiPhase);

rxarray = phased.ConformalArray(‘Element’,AntElem_Patch,…

‘ElementPosition’,’???’);

rxcollector = phased.Collector(‘Sensor’,rxarray,’OperatingFrequency’,Freq,…

‘PropagationSpeed’,c); radar, phased array MATLAB Answers — New Questions

## Help needed to make a 3d contour plot

Hello. I have around 50K data points (x,y,z co-ordinates of each point) and the value of a function at each of these points. I want to make a filled contour plot of this function on the 3d surface that would so be formed by joining all the data points. I have tried various functions like contour3, tricontour, scatter3, surf etc but nothing seems to work. If it matters, the value of the function is in no way dependent on the co-ordinates of the point.

As an example to clear things up, <http://imgur.com/tmW4X5b this> is what I want to plot.Hello. I have around 50K data points (x,y,z co-ordinates of each point) and the value of a function at each of these points. I want to make a filled contour plot of this function on the 3d surface that would so be formed by joining all the data points. I have tried various functions like contour3, tricontour, scatter3, surf etc but nothing seems to work. If it matters, the value of the function is in no way dependent on the co-ordinates of the point.

As an example to clear things up, <http://imgur.com/tmW4X5b this> is what I want to plot. Hello. I have around 50K data points (x,y,z co-ordinates of each point) and the value of a function at each of these points. I want to make a filled contour plot of this function on the 3d surface that would so be formed by joining all the data points. I have tried various functions like contour3, tricontour, scatter3, surf etc but nothing seems to work. If it matters, the value of the function is in no way dependent on the co-ordinates of the point.

As an example to clear things up, <http://imgur.com/tmW4X5b this> is what I want to plot. contour, contour3, surf, surf3, 3d plots, plot MATLAB Answers — New Questions

## How can I add dates to bar charts when the data I am plotting are matrices?

I am trying to plot a matrix of N * 7 elements in a bar chart.

N are different dates for which I have 7 variables under study. If I have N around 8, the graph looks nice and it shows what I want. Namely, the date for the group of variables on the x axis. However, if I have N = 20 or bigger it only shows the first five dates spanning the whole x-axis.

The code I am using right now is the following:

width = 6; % Width in inches

height = 3; % Height in inches

%FIGURE 1: Sectors Jump Days

fig1=figure(1);

pos = get(gcf, ‘Position’);

set(gcf, ‘Position’, [pos(1) pos(2) width*100, height*100])

bar(AverageTime)

set(gca,’XTickLabel’,dayIndjumpStr)

legend(‘Primary’,’Manufacturing’,’Transport’,’Trade’,’Finance’,’Services’,’PA’)

and dayIndjumpstr is a cell array.

Thank you very much.I am trying to plot a matrix of N * 7 elements in a bar chart.

N are different dates for which I have 7 variables under study. If I have N around 8, the graph looks nice and it shows what I want. Namely, the date for the group of variables on the x axis. However, if I have N = 20 or bigger it only shows the first five dates spanning the whole x-axis.

The code I am using right now is the following:

width = 6; % Width in inches

height = 3; % Height in inches

%FIGURE 1: Sectors Jump Days

fig1=figure(1);

pos = get(gcf, ‘Position’);

set(gcf, ‘Position’, [pos(1) pos(2) width*100, height*100])

bar(AverageTime)

set(gca,’XTickLabel’,dayIndjumpStr)

legend(‘Primary’,’Manufacturing’,’Transport’,’Trade’,’Finance’,’Services’,’PA’)

and dayIndjumpstr is a cell array.

Thank you very much. I am trying to plot a matrix of N * 7 elements in a bar chart.

N are different dates for which I have 7 variables under study. If I have N around 8, the graph looks nice and it shows what I want. Namely, the date for the group of variables on the x axis. However, if I have N = 20 or bigger it only shows the first five dates spanning the whole x-axis.

The code I am using right now is the following:

width = 6; % Width in inches

height = 3; % Height in inches

%FIGURE 1: Sectors Jump Days

fig1=figure(1);

pos = get(gcf, ‘Position’);

set(gcf, ‘Position’, [pos(1) pos(2) width*100, height*100])

bar(AverageTime)

set(gca,’XTickLabel’,dayIndjumpStr)

legend(‘Primary’,’Manufacturing’,’Transport’,’Trade’,’Finance’,’Services’,’PA’)

and dayIndjumpstr is a cell array.

Thank you very much. bar charts dates MATLAB Answers — New Questions

## Non-Virtual-Bus setting not recognized when integrating an FMU file

I have successfully compiled and created a FMU from a model with the Simulink Coder.

The Model accepts and exports a Simulink Bus structure as FMI from/to the parent model.

When running the parent model, which integrates the FMU (see first picture below) the following error message is shown:

Error:’Output Port 1′ of ‘MyModel/FMU’ expects a nonvirtual bus or nonbus signal but receives a virtual bus. Convert the virtual bus to a nonvirtual bus or vector using a Signal Conversion or Bus to Vector block.

Here is the original Error message and the relevant part of the parent model:

An this is the model and the port configuration which is converted to the FMU:

The question is, why is the error message still created, even though the port setting is correct?

Regards.I have successfully compiled and created a FMU from a model with the Simulink Coder.

The Model accepts and exports a Simulink Bus structure as FMI from/to the parent model.

When running the parent model, which integrates the FMU (see first picture below) the following error message is shown:

Error:’Output Port 1′ of ‘MyModel/FMU’ expects a nonvirtual bus or nonbus signal but receives a virtual bus. Convert the virtual bus to a nonvirtual bus or vector using a Signal Conversion or Bus to Vector block.

Here is the original Error message and the relevant part of the parent model:

An this is the model and the port configuration which is converted to the FMU:

The question is, why is the error message still created, even though the port setting is correct?

Regards. I have successfully compiled and created a FMU from a model with the Simulink Coder.

The Model accepts and exports a Simulink Bus structure as FMI from/to the parent model.

When running the parent model, which integrates the FMU (see first picture below) the following error message is shown:

Error:’Output Port 1′ of ‘MyModel/FMU’ expects a nonvirtual bus or nonbus signal but receives a virtual bus. Convert the virtual bus to a nonvirtual bus or vector using a Signal Conversion or Bus to Vector block.

Here is the original Error message and the relevant part of the parent model:

An this is the model and the port configuration which is converted to the FMU:

The question is, why is the error message still created, even though the port setting is correct?

Regards. fmu, non-virtual-bua MATLAB Answers — New Questions

## How to read grib files

I have tried to read grib files with thisfunction but it always displaies

Error using readgrib (line 39)

Not enough input arguments.I have tried to read grib files with thisfunction but it always displaies

Error using readgrib (line 39)

Not enough input arguments. I have tried to read grib files with thisfunction but it always displaies

Error using readgrib (line 39)

Not enough input arguments. grib MATLAB Answers — New Questions

## Ternary plot (Contour lines)

Hi, I am trying to draw some contour lines of a ternary phase diagram. I am currently just using closely spaced digitized points on the ternary plot. I am using the package: Ternary Plots. However, I want smooth lines connecting them. So far, I have this:

The code is:

B = readmatrix(‘dataset.xlsx’);

close all

clc

B1 = B*0.01; %liquidus line

fig = figure(‘units’,’pixels’,’position’,[100 100 1000 800]);

colormap(jet)

%– Plot the axis system

[h,htick]=terplot3;

hter1=ternaryc(B1(1:188,1),B1(1:188,2),B1(1:188,3)); %phase boundaries

set(hter1,’marker’,’o’,’markerfacecolor’,’none’,’markersize’,4)

hlabels=terlabel2(‘MnO’,’Al_2O_3′,’SiO_2′);

The dataset is here. Thanks for any help.Hi, I am trying to draw some contour lines of a ternary phase diagram. I am currently just using closely spaced digitized points on the ternary plot. I am using the package: Ternary Plots. However, I want smooth lines connecting them. So far, I have this:

The code is:

B = readmatrix(‘dataset.xlsx’);

close all

clc

B1 = B*0.01; %liquidus line

fig = figure(‘units’,’pixels’,’position’,[100 100 1000 800]);

colormap(jet)

%– Plot the axis system

[h,htick]=terplot3;

hter1=ternaryc(B1(1:188,1),B1(1:188,2),B1(1:188,3)); %phase boundaries

set(hter1,’marker’,’o’,’markerfacecolor’,’none’,’markersize’,4)

hlabels=terlabel2(‘MnO’,’Al_2O_3′,’SiO_2′);

The dataset is here. Thanks for any help. Hi, I am trying to draw some contour lines of a ternary phase diagram. I am currently just using closely spaced digitized points on the ternary plot. I am using the package: Ternary Plots. However, I want smooth lines connecting them. So far, I have this:

The code is:

B = readmatrix(‘dataset.xlsx’);

close all

clc

B1 = B*0.01; %liquidus line

fig = figure(‘units’,’pixels’,’position’,[100 100 1000 800]);

colormap(jet)

%– Plot the axis system

[h,htick]=terplot3;

hter1=ternaryc(B1(1:188,1),B1(1:188,2),B1(1:188,3)); %phase boundaries

set(hter1,’marker’,’o’,’markerfacecolor’,’none’,’markersize’,4)

hlabels=terlabel2(‘MnO’,’Al_2O_3′,’SiO_2′);

The dataset is here. Thanks for any help. ternary, plot MATLAB Answers — New Questions

## Simscape mechanics explorer ERROR: Model dispersion

When I run the offical model of stewart platform with MATLABSimulink R2022b, the model in mechanic explorer is a decentralized state. These components seem to be much smaller than they should be.

When I show all the frames/CGs, the proportion is correct. Just all the solid blocks become so smaller that I cant even see them in a view.

Anyone can help? I really appreciate it.When I run the offical model of stewart platform with MATLABSimulink R2022b, the model in mechanic explorer is a decentralized state. These components seem to be much smaller than they should be.

When I show all the frames/CGs, the proportion is correct. Just all the solid blocks become so smaller that I cant even see them in a view.

Anyone can help? I really appreciate it. When I run the offical model of stewart platform with MATLABSimulink R2022b, the model in mechanic explorer is a decentralized state. These components seem to be much smaller than they should be.

When I show all the frames/CGs, the proportion is correct. Just all the solid blocks become so smaller that I cant even see them in a view.

Anyone can help? I really appreciate it. simscape, simulation MATLAB Answers — New Questions