Category: Matlab
Category Archives: Matlab
How to read data from input boxes in app design using MATLAB
I have created an app, such that the response will be dynamically changing w.r.t input given. For example, the design view will have numeric edit field as No. of rooms and start button. If user give some value in No. of rooms, those many tabs will be generated with edit fields: Room no., No. of baskets in each room, percentage of fruits in each basket, No. of mangoes in each basket and also able to generate input boxes based on inputs given. There are few issues: Issue_1: Even though i’m not entering any value in room number and percentage of fruits in each basket, the app is able to generate next steps, that should not happen, instead the app should proceed for next steps after entering some value in room no and percentage of fruits in each basket. Issue_2: If I decrease the numeric value in No. of mangoes in each basket, the ‘import excel’ button are not able to change(By mistakenly if i have given 3,7,4 and press enter again if i have to give 2,3,2 the ‘import excel’ button won’t change).Issue_3: Need to plot the graph in such a format like(Room No.’x’_ basket’y’_’z’%of fruits in ‘y’ basket_Mango_’n’) and so on, which means for each ‘excel read’ button the graph should be displayed in an order on the tab. I have attached the app file and data required for plotting graphs.I have created an app, such that the response will be dynamically changing w.r.t input given. For example, the design view will have numeric edit field as No. of rooms and start button. If user give some value in No. of rooms, those many tabs will be generated with edit fields: Room no., No. of baskets in each room, percentage of fruits in each basket, No. of mangoes in each basket and also able to generate input boxes based on inputs given. There are few issues: Issue_1: Even though i’m not entering any value in room number and percentage of fruits in each basket, the app is able to generate next steps, that should not happen, instead the app should proceed for next steps after entering some value in room no and percentage of fruits in each basket. Issue_2: If I decrease the numeric value in No. of mangoes in each basket, the ‘import excel’ button are not able to change(By mistakenly if i have given 3,7,4 and press enter again if i have to give 2,3,2 the ‘import excel’ button won’t change).Issue_3: Need to plot the graph in such a format like(Room No.’x’_ basket’y’_’z’%of fruits in ‘y’ basket_Mango_’n’) and so on, which means for each ‘excel read’ button the graph should be displayed in an order on the tab. I have attached the app file and data required for plotting graphs. I have created an app, such that the response will be dynamically changing w.r.t input given. For example, the design view will have numeric edit field as No. of rooms and start button. If user give some value in No. of rooms, those many tabs will be generated with edit fields: Room no., No. of baskets in each room, percentage of fruits in each basket, No. of mangoes in each basket and also able to generate input boxes based on inputs given. There are few issues: Issue_1: Even though i’m not entering any value in room number and percentage of fruits in each basket, the app is able to generate next steps, that should not happen, instead the app should proceed for next steps after entering some value in room no and percentage of fruits in each basket. Issue_2: If I decrease the numeric value in No. of mangoes in each basket, the ‘import excel’ button are not able to change(By mistakenly if i have given 3,7,4 and press enter again if i have to give 2,3,2 the ‘import excel’ button won’t change).Issue_3: Need to plot the graph in such a format like(Room No.’x’_ basket’y’_’z’%of fruits in ‘y’ basket_Mango_’n’) and so on, which means for each ‘excel read’ button the graph should be displayed in an order on the tab. I have attached the app file and data required for plotting graphs. matlab, appdesigner MATLAB Answers — New Questions
Unable to complete PX4 support packages due to unresponsive firmware upload menu?
During Hardware setup for PX4 support packages, there is a compulsion intrduced to upload the firmware, but it became unresponsive and didn’t stop or close unless I kill that terminal process manually. When I searched for the solution the help page only covers for Windows users, since I am on Ubutntu 22.04, I can’t apply the solution, Kindly help me as soon as possible.During Hardware setup for PX4 support packages, there is a compulsion intrduced to upload the firmware, but it became unresponsive and didn’t stop or close unless I kill that terminal process manually. When I searched for the solution the help page only covers for Windows users, since I am on Ubutntu 22.04, I can’t apply the solution, Kindly help me as soon as possible. During Hardware setup for PX4 support packages, there is a compulsion intrduced to upload the firmware, but it became unresponsive and didn’t stop or close unless I kill that terminal process manually. When I searched for the solution the help page only covers for Windows users, since I am on Ubutntu 22.04, I can’t apply the solution, Kindly help me as soon as possible. px4, uav support packages, px4 hardware support packages MATLAB Answers — New Questions
Score transform for RUSBoost in fitcensemble
The documentation for the predict function of fitcensemble lists the score transforms (to convert scores to probabilities) for the following model methods:
Bag (none)
AdaBoostM1 (doublelogit)
GentleBoost (doublelogit)
LogitBoost (doublelogit)
But it does not list a score transform for several other possible fitcensemble methods. Are these documented somewhere else?
I’m currently most interested in RUSBoost, because that is the method I am using.The documentation for the predict function of fitcensemble lists the score transforms (to convert scores to probabilities) for the following model methods:
Bag (none)
AdaBoostM1 (doublelogit)
GentleBoost (doublelogit)
LogitBoost (doublelogit)
But it does not list a score transform for several other possible fitcensemble methods. Are these documented somewhere else?
I’m currently most interested in RUSBoost, because that is the method I am using. The documentation for the predict function of fitcensemble lists the score transforms (to convert scores to probabilities) for the following model methods:
Bag (none)
AdaBoostM1 (doublelogit)
GentleBoost (doublelogit)
LogitBoost (doublelogit)
But it does not list a score transform for several other possible fitcensemble methods. Are these documented somewhere else?
I’m currently most interested in RUSBoost, because that is the method I am using. fitcensemble, score transform MATLAB Answers — New Questions
Need to calculate 12 experimental coefficients highlighted in red. Have found F’n and F’t values with 200 samples, and all other values like Vw, Vc, a, de, Cs are known.
I need to calculate experimental coefficients K, K1, K4, a0, b0, c0 using F’n 200 sample experimental values. Similarly K’, K2, K3, a0, b0, c0 to be calculated using F’t 200 sample experimental values. Note that Vw, Vc, a, de, Cs values are known for 200 sample values. Please help in with this matlab program.I need to calculate experimental coefficients K, K1, K4, a0, b0, c0 using F’n 200 sample experimental values. Similarly K’, K2, K3, a0, b0, c0 to be calculated using F’t 200 sample experimental values. Note that Vw, Vc, a, de, Cs values are known for 200 sample values. Please help in with this matlab program. I need to calculate experimental coefficients K, K1, K4, a0, b0, c0 using F’n 200 sample experimental values. Similarly K’, K2, K3, a0, b0, c0 to be calculated using F’t 200 sample experimental values. Note that Vw, Vc, a, de, Cs values are known for 200 sample values. Please help in with this matlab program. regression, polynomial regression, curve fitting MATLAB Answers — New Questions
How do I lower an image quality?
I’m new to matlab and need to create a for loop that gradually lowers the quality of an image in a GUI. I tried searching on the internet but can’t find how to do it. I’m aware it’s probably imwrite but I can’t get it to work properly.
The image is .jpeg format, I just need to know how to lower it once and I’ll figure everything else from there.I’m new to matlab and need to create a for loop that gradually lowers the quality of an image in a GUI. I tried searching on the internet but can’t find how to do it. I’m aware it’s probably imwrite but I can’t get it to work properly.
The image is .jpeg format, I just need to know how to lower it once and I’ll figure everything else from there. I’m new to matlab and need to create a for loop that gradually lowers the quality of an image in a GUI. I tried searching on the internet but can’t find how to do it. I’m aware it’s probably imwrite but I can’t get it to work properly.
The image is .jpeg format, I just need to know how to lower it once and I’ll figure everything else from there. matlab gui, image processing MATLAB Answers — New Questions
Scatter plot text behind plotted data when image copied.
I have a figure containing a scatter plot overlaid with a fitted poly. I have added some text labels to the data.
When I copy the image and paste as enhanced metafile, the text appears behind the plotted data, even when I set the text object to ‘top’ and/or set the current axes to ‘top’:
t = text(x, y, str); % Adding a text label
uistack(t, ‘top’); % Bring the text to the front
set(gca, ‘Layer’, ‘top’);
If I change the renderer to ‘opengl’, the image copies correctly, but the pasted image quality is very poor.
This behaviour is repeatable on any figure of this type.I have a figure containing a scatter plot overlaid with a fitted poly. I have added some text labels to the data.
When I copy the image and paste as enhanced metafile, the text appears behind the plotted data, even when I set the text object to ‘top’ and/or set the current axes to ‘top’:
t = text(x, y, str); % Adding a text label
uistack(t, ‘top’); % Bring the text to the front
set(gca, ‘Layer’, ‘top’);
If I change the renderer to ‘opengl’, the image copies correctly, but the pasted image quality is very poor.
This behaviour is repeatable on any figure of this type. I have a figure containing a scatter plot overlaid with a fitted poly. I have added some text labels to the data.
When I copy the image and paste as enhanced metafile, the text appears behind the plotted data, even when I set the text object to ‘top’ and/or set the current axes to ‘top’:
t = text(x, y, str); % Adding a text label
uistack(t, ‘top’); % Bring the text to the front
set(gca, ‘Layer’, ‘top’);
If I change the renderer to ‘opengl’, the image copies correctly, but the pasted image quality is very poor.
This behaviour is repeatable on any figure of this type. scatter plot, plot text, renderer, figure copy MATLAB Answers — New Questions
Need help with restricted areas and warp gates
clc
% Prompts user for the desired input method
Input = input(‘Type of input (User or File): ‘, ‘s’);
if strcmp(Input, ‘file’)
% File input
filename = input(‘Filename ‘, ‘s’);
fid = fopen(filename);
Width = fscanf(fid, ‘%f’,1);
Radius = fscanf(fid, ‘%f’,1);
Direction = fscanf(fid,’%f’, 1);
Coords = fscanf(fid, ‘%f’, [2,inf]);
fclose(fid);
Window = createWindowS24(Width);
Alpha = []; % List of ball handles
for i =1:size(Coords,2)
Alpha(i) = drawBall(Coords(1,i), Coords(2, i), Radius,’g’);
end
else
% User input
Width = input(‘Please input desired width of the window: ‘);
Radius = input(‘Please input desired radius of the balls: ‘);
BallNumber = input(‘Please input the desired number of balls: ‘);
Direction = input(‘Please input the desired start position of the balls (deg): ‘);
Window = createWindowS24(Width);
Alpha = []; % List of ball handles
for i = 1:BallNumber
while true
Bravo= randi([Radius,Width – Radius]);
Charlie= randi([Radius, Width-Radius]);
% Check for overlap with existing balls
overlap = false;
for j = 1:length(Alpha)
[xc, yc] = getCenter(Alpha(j));
if norm([Bravo – xc, Charlie – yc]) < 2 * Radius
overlap = true;
break;
end
end
if ~overlap
break;
end
end
Alpha(i) = drawBall(Bravo, Charlie, Radius, ‘b’);
end
end
BallNumber = numel(Alpha);
Direction = Direction*ones(1, BallNumber);
while true
for i = 1:BallNumber
[Bravo, Charlie] = getCenter(Alpha(i));
Delta= Bravo + cosd(Direction(i));
Echo= Charlie + sind(Direction(i));
if Delta <Radius|| Delta>Width- Radius
Direction(i) = 180 – Direction(i);
end
if Echo < Radius || Echo > Width -Radius
Direction(i)=-Direction(i);
end
xMove(Alpha(i), cosd(Direction(i)));
yMove(Alpha(i), sind(Direction(i)));
end
for i = 1:BallNumber
for j = (i + 1):BallNumber
[x1, y1] = getCenter(Alpha(i));
[x2, y2] = getCenter(Alpha(j));
% Check if two balls collide
Collision = sqrt((x2-x1)^2 + (y2 – y1)^2);
if Collision <2*Radius
% Calculate the angle of collision
CAngle = atan2d(y2 – y1, x2 – x1);
% Update directions after collision (elastic collision)
Direction1=[cosd(Direction(i)), sind(Direction(i))];
Direction2 = [cosd(Direction(j)), sind(Direction(j))];
EC = [(x2-x1)/Collision,(y2-y1)/Collision];
Dir1F = Direction1 – 2*dot(Direction1, EC) * EC;
Dir2F = Direction2 – 2 * dot(Direction2, EC) * EC;
Direction(i) = atan2d(Dir1F(2),Dir1F(1));
Direction(j) = atan2d(Dir2F(2),Dir2F(1));
end
end
end
% Redraw all objects
redraw();
end
I have this quite long code for some balls that will collide with each other and the window bounds. However, I cannot seem to figure out how to make it collide with the restricted area and go through the warp gates. Any assistance would be appreciated. Below this is the function for the window, if that helps.
function f = createWindowS24(w)
close all
% createWindowall(w)
% function to create a square window whose width is w pixels and
% whose height is w pixels; its bottom left corner is placed
% 50 pixels up and 50 pixels to the right of the bottom left
% corner of the monitor
% This version of the function also generates a restricted zone in the top
% left and top right corners of the square.
% (note: the function returns a handle to the window, if needed;
% usage would then need to be f=createWindowS24(w)
left = 50;
bottom = 50;
pos = [left bottom w w];
f = figure;
set (f, ‘Position’, pos)
set (f, ‘MenuBar’, ‘none’)
set (f, ‘Name’, ‘AE 227 – Spring 2024’)
x = [0 w];
y = [0 w];
hold on
axis equal
axis ([x y])
axis off
x1=[0,w,w,0,0];
y1=[0,0,w,w,0];
fill(x1,y1,[1,1,1]); %draw the boundary
%Top Left
x2 = [0,0,w/2,0];
y2 = [w/2,w,w,w/2];
fill(x2,y2,[0.5 0.5 0.5])
%Top Right
x3 = [w/2,w,w];
y3 = [w,w,w/2];
fill(x3,y3,[0.5 0.5 0.5])
diff=0.01*w;
%Top Left Diagonal Warp
x5=[w/6,w/6-diff,w/3-diff,w/3,w/6];
y5=[2*w/3,2*w/3+diff,5*w/6+diff,5*w/6,2*w/3];
fill(x5,y5,[.6,.6,1]);
%Top Right Diagonal Warp
x5=[5*w/6,5*w/6+diff,2*w/3+diff,2*w/3,5*w/6];
y5=[2*w/3,2*w/3+diff,5*w/6+diff,5*w/6,2*w/3];
fill(x5,y5,[.6,.6,1]);clc
% Prompts user for the desired input method
Input = input(‘Type of input (User or File): ‘, ‘s’);
if strcmp(Input, ‘file’)
% File input
filename = input(‘Filename ‘, ‘s’);
fid = fopen(filename);
Width = fscanf(fid, ‘%f’,1);
Radius = fscanf(fid, ‘%f’,1);
Direction = fscanf(fid,’%f’, 1);
Coords = fscanf(fid, ‘%f’, [2,inf]);
fclose(fid);
Window = createWindowS24(Width);
Alpha = []; % List of ball handles
for i =1:size(Coords,2)
Alpha(i) = drawBall(Coords(1,i), Coords(2, i), Radius,’g’);
end
else
% User input
Width = input(‘Please input desired width of the window: ‘);
Radius = input(‘Please input desired radius of the balls: ‘);
BallNumber = input(‘Please input the desired number of balls: ‘);
Direction = input(‘Please input the desired start position of the balls (deg): ‘);
Window = createWindowS24(Width);
Alpha = []; % List of ball handles
for i = 1:BallNumber
while true
Bravo= randi([Radius,Width – Radius]);
Charlie= randi([Radius, Width-Radius]);
% Check for overlap with existing balls
overlap = false;
for j = 1:length(Alpha)
[xc, yc] = getCenter(Alpha(j));
if norm([Bravo – xc, Charlie – yc]) < 2 * Radius
overlap = true;
break;
end
end
if ~overlap
break;
end
end
Alpha(i) = drawBall(Bravo, Charlie, Radius, ‘b’);
end
end
BallNumber = numel(Alpha);
Direction = Direction*ones(1, BallNumber);
while true
for i = 1:BallNumber
[Bravo, Charlie] = getCenter(Alpha(i));
Delta= Bravo + cosd(Direction(i));
Echo= Charlie + sind(Direction(i));
if Delta <Radius|| Delta>Width- Radius
Direction(i) = 180 – Direction(i);
end
if Echo < Radius || Echo > Width -Radius
Direction(i)=-Direction(i);
end
xMove(Alpha(i), cosd(Direction(i)));
yMove(Alpha(i), sind(Direction(i)));
end
for i = 1:BallNumber
for j = (i + 1):BallNumber
[x1, y1] = getCenter(Alpha(i));
[x2, y2] = getCenter(Alpha(j));
% Check if two balls collide
Collision = sqrt((x2-x1)^2 + (y2 – y1)^2);
if Collision <2*Radius
% Calculate the angle of collision
CAngle = atan2d(y2 – y1, x2 – x1);
% Update directions after collision (elastic collision)
Direction1=[cosd(Direction(i)), sind(Direction(i))];
Direction2 = [cosd(Direction(j)), sind(Direction(j))];
EC = [(x2-x1)/Collision,(y2-y1)/Collision];
Dir1F = Direction1 – 2*dot(Direction1, EC) * EC;
Dir2F = Direction2 – 2 * dot(Direction2, EC) * EC;
Direction(i) = atan2d(Dir1F(2),Dir1F(1));
Direction(j) = atan2d(Dir2F(2),Dir2F(1));
end
end
end
% Redraw all objects
redraw();
end
I have this quite long code for some balls that will collide with each other and the window bounds. However, I cannot seem to figure out how to make it collide with the restricted area and go through the warp gates. Any assistance would be appreciated. Below this is the function for the window, if that helps.
function f = createWindowS24(w)
close all
% createWindowall(w)
% function to create a square window whose width is w pixels and
% whose height is w pixels; its bottom left corner is placed
% 50 pixels up and 50 pixels to the right of the bottom left
% corner of the monitor
% This version of the function also generates a restricted zone in the top
% left and top right corners of the square.
% (note: the function returns a handle to the window, if needed;
% usage would then need to be f=createWindowS24(w)
left = 50;
bottom = 50;
pos = [left bottom w w];
f = figure;
set (f, ‘Position’, pos)
set (f, ‘MenuBar’, ‘none’)
set (f, ‘Name’, ‘AE 227 – Spring 2024’)
x = [0 w];
y = [0 w];
hold on
axis equal
axis ([x y])
axis off
x1=[0,w,w,0,0];
y1=[0,0,w,w,0];
fill(x1,y1,[1,1,1]); %draw the boundary
%Top Left
x2 = [0,0,w/2,0];
y2 = [w/2,w,w,w/2];
fill(x2,y2,[0.5 0.5 0.5])
%Top Right
x3 = [w/2,w,w];
y3 = [w,w,w/2];
fill(x3,y3,[0.5 0.5 0.5])
diff=0.01*w;
%Top Left Diagonal Warp
x5=[w/6,w/6-diff,w/3-diff,w/3,w/6];
y5=[2*w/3,2*w/3+diff,5*w/6+diff,5*w/6,2*w/3];
fill(x5,y5,[.6,.6,1]);
%Top Right Diagonal Warp
x5=[5*w/6,5*w/6+diff,2*w/3+diff,2*w/3,5*w/6];
y5=[2*w/3,2*w/3+diff,5*w/6+diff,5*w/6,2*w/3];
fill(x5,y5,[.6,.6,1]); clc
% Prompts user for the desired input method
Input = input(‘Type of input (User or File): ‘, ‘s’);
if strcmp(Input, ‘file’)
% File input
filename = input(‘Filename ‘, ‘s’);
fid = fopen(filename);
Width = fscanf(fid, ‘%f’,1);
Radius = fscanf(fid, ‘%f’,1);
Direction = fscanf(fid,’%f’, 1);
Coords = fscanf(fid, ‘%f’, [2,inf]);
fclose(fid);
Window = createWindowS24(Width);
Alpha = []; % List of ball handles
for i =1:size(Coords,2)
Alpha(i) = drawBall(Coords(1,i), Coords(2, i), Radius,’g’);
end
else
% User input
Width = input(‘Please input desired width of the window: ‘);
Radius = input(‘Please input desired radius of the balls: ‘);
BallNumber = input(‘Please input the desired number of balls: ‘);
Direction = input(‘Please input the desired start position of the balls (deg): ‘);
Window = createWindowS24(Width);
Alpha = []; % List of ball handles
for i = 1:BallNumber
while true
Bravo= randi([Radius,Width – Radius]);
Charlie= randi([Radius, Width-Radius]);
% Check for overlap with existing balls
overlap = false;
for j = 1:length(Alpha)
[xc, yc] = getCenter(Alpha(j));
if norm([Bravo – xc, Charlie – yc]) < 2 * Radius
overlap = true;
break;
end
end
if ~overlap
break;
end
end
Alpha(i) = drawBall(Bravo, Charlie, Radius, ‘b’);
end
end
BallNumber = numel(Alpha);
Direction = Direction*ones(1, BallNumber);
while true
for i = 1:BallNumber
[Bravo, Charlie] = getCenter(Alpha(i));
Delta= Bravo + cosd(Direction(i));
Echo= Charlie + sind(Direction(i));
if Delta <Radius|| Delta>Width- Radius
Direction(i) = 180 – Direction(i);
end
if Echo < Radius || Echo > Width -Radius
Direction(i)=-Direction(i);
end
xMove(Alpha(i), cosd(Direction(i)));
yMove(Alpha(i), sind(Direction(i)));
end
for i = 1:BallNumber
for j = (i + 1):BallNumber
[x1, y1] = getCenter(Alpha(i));
[x2, y2] = getCenter(Alpha(j));
% Check if two balls collide
Collision = sqrt((x2-x1)^2 + (y2 – y1)^2);
if Collision <2*Radius
% Calculate the angle of collision
CAngle = atan2d(y2 – y1, x2 – x1);
% Update directions after collision (elastic collision)
Direction1=[cosd(Direction(i)), sind(Direction(i))];
Direction2 = [cosd(Direction(j)), sind(Direction(j))];
EC = [(x2-x1)/Collision,(y2-y1)/Collision];
Dir1F = Direction1 – 2*dot(Direction1, EC) * EC;
Dir2F = Direction2 – 2 * dot(Direction2, EC) * EC;
Direction(i) = atan2d(Dir1F(2),Dir1F(1));
Direction(j) = atan2d(Dir2F(2),Dir2F(1));
end
end
end
% Redraw all objects
redraw();
end
I have this quite long code for some balls that will collide with each other and the window bounds. However, I cannot seem to figure out how to make it collide with the restricted area and go through the warp gates. Any assistance would be appreciated. Below this is the function for the window, if that helps.
function f = createWindowS24(w)
close all
% createWindowall(w)
% function to create a square window whose width is w pixels and
% whose height is w pixels; its bottom left corner is placed
% 50 pixels up and 50 pixels to the right of the bottom left
% corner of the monitor
% This version of the function also generates a restricted zone in the top
% left and top right corners of the square.
% (note: the function returns a handle to the window, if needed;
% usage would then need to be f=createWindowS24(w)
left = 50;
bottom = 50;
pos = [left bottom w w];
f = figure;
set (f, ‘Position’, pos)
set (f, ‘MenuBar’, ‘none’)
set (f, ‘Name’, ‘AE 227 – Spring 2024’)
x = [0 w];
y = [0 w];
hold on
axis equal
axis ([x y])
axis off
x1=[0,w,w,0,0];
y1=[0,0,w,w,0];
fill(x1,y1,[1,1,1]); %draw the boundary
%Top Left
x2 = [0,0,w/2,0];
y2 = [w/2,w,w,w/2];
fill(x2,y2,[0.5 0.5 0.5])
%Top Right
x3 = [w/2,w,w];
y3 = [w,w,w/2];
fill(x3,y3,[0.5 0.5 0.5])
diff=0.01*w;
%Top Left Diagonal Warp
x5=[w/6,w/6-diff,w/3-diff,w/3,w/6];
y5=[2*w/3,2*w/3+diff,5*w/6+diff,5*w/6,2*w/3];
fill(x5,y5,[.6,.6,1]);
%Top Right Diagonal Warp
x5=[5*w/6,5*w/6+diff,2*w/3+diff,2*w/3,5*w/6];
y5=[2*w/3,2*w/3+diff,5*w/6+diff,5*w/6,2*w/3];
fill(x5,y5,[.6,.6,1]); matlab code, function MATLAB Answers — New Questions
Layer Input Expectation Doesn’t Match (Neural Network)
Creating a dlnetwork with three inputs and two outputs. The inputs are x, y, z coordinates in the form of UTMN, UTME, and height. The outputs are pressure and temperature. Data is from multiple well logs and is organized by well ID, UTMN, UTME, height, temp, and pressure.
I seperated the data into training and validation sets. Training data: train_x_array (3 feature inputs) and train_y_array (2 feature outputs). Validation: val_x_array and val_y_array.
Keep getting errors such as:
Training stopped: Error occurred
Error using trainnet
Layer ‘input’: Invalid input data. Invalid size of channel dimension. Layer expects input with channel dimension size 3
but received input with size 189.
Error in final3 (line 25)
netTrained = trainnet(train_x_array_transposed, train_y_array_transposed, net,"mse", opts);
In an effort to fix the issue, I transposed the x and y arrays for both the training and validation sets. However, I am still getting the same error. I am at a loss for how to fix the error. If I try to use the Deep Network Designer, I receive an error stating their are multiple observations. The x and y values are the same for different heights/temps/pressures from the same well. I am assuming this is were the issue arises, but I do not understand why the designer would produce a different error.
Example data (before transposing):
x y z T P
4407300 327880 2796 344.3 501
4407300 327880 2746 356.5 521
4407300 327880 2696 357 541
Where train_x would be the first 3 columns, and train_y is the last 2.
Full Code:
inputSize = 3;
hiddenLayerSize = 20;
outputSize = 2;
layers = [
featureInputLayer(inputSize)
fullyConnectedLayer(hiddenLayerSize, ‘Name’, ‘fc1’)
reluLayer(‘Name’, ‘relu1’)
fullyConnectedLayer(outputSize, ‘Name’, ‘output’)
];
net = dlnetwork(layers);
opts = trainingOptions(‘adam’, …
‘MaxEpochs’, 100, …
‘MiniBatchSize’, 64, …
‘ValidationData’, {val_x_array_transposed’, val_y_array_transposed’}, …
‘ValidationFrequency’, 10, …
‘Verbose’, true …
);
netTrained = trainnet(train_x_array_transposed, train_y_array_transposed, net,"mse", opts);
Y_pred_val = predict(netTrained, val_x_array’);Creating a dlnetwork with three inputs and two outputs. The inputs are x, y, z coordinates in the form of UTMN, UTME, and height. The outputs are pressure and temperature. Data is from multiple well logs and is organized by well ID, UTMN, UTME, height, temp, and pressure.
I seperated the data into training and validation sets. Training data: train_x_array (3 feature inputs) and train_y_array (2 feature outputs). Validation: val_x_array and val_y_array.
Keep getting errors such as:
Training stopped: Error occurred
Error using trainnet
Layer ‘input’: Invalid input data. Invalid size of channel dimension. Layer expects input with channel dimension size 3
but received input with size 189.
Error in final3 (line 25)
netTrained = trainnet(train_x_array_transposed, train_y_array_transposed, net,"mse", opts);
In an effort to fix the issue, I transposed the x and y arrays for both the training and validation sets. However, I am still getting the same error. I am at a loss for how to fix the error. If I try to use the Deep Network Designer, I receive an error stating their are multiple observations. The x and y values are the same for different heights/temps/pressures from the same well. I am assuming this is were the issue arises, but I do not understand why the designer would produce a different error.
Example data (before transposing):
x y z T P
4407300 327880 2796 344.3 501
4407300 327880 2746 356.5 521
4407300 327880 2696 357 541
Where train_x would be the first 3 columns, and train_y is the last 2.
Full Code:
inputSize = 3;
hiddenLayerSize = 20;
outputSize = 2;
layers = [
featureInputLayer(inputSize)
fullyConnectedLayer(hiddenLayerSize, ‘Name’, ‘fc1’)
reluLayer(‘Name’, ‘relu1’)
fullyConnectedLayer(outputSize, ‘Name’, ‘output’)
];
net = dlnetwork(layers);
opts = trainingOptions(‘adam’, …
‘MaxEpochs’, 100, …
‘MiniBatchSize’, 64, …
‘ValidationData’, {val_x_array_transposed’, val_y_array_transposed’}, …
‘ValidationFrequency’, 10, …
‘Verbose’, true …
);
netTrained = trainnet(train_x_array_transposed, train_y_array_transposed, net,"mse", opts);
Y_pred_val = predict(netTrained, val_x_array’); Creating a dlnetwork with three inputs and two outputs. The inputs are x, y, z coordinates in the form of UTMN, UTME, and height. The outputs are pressure and temperature. Data is from multiple well logs and is organized by well ID, UTMN, UTME, height, temp, and pressure.
I seperated the data into training and validation sets. Training data: train_x_array (3 feature inputs) and train_y_array (2 feature outputs). Validation: val_x_array and val_y_array.
Keep getting errors such as:
Training stopped: Error occurred
Error using trainnet
Layer ‘input’: Invalid input data. Invalid size of channel dimension. Layer expects input with channel dimension size 3
but received input with size 189.
Error in final3 (line 25)
netTrained = trainnet(train_x_array_transposed, train_y_array_transposed, net,"mse", opts);
In an effort to fix the issue, I transposed the x and y arrays for both the training and validation sets. However, I am still getting the same error. I am at a loss for how to fix the error. If I try to use the Deep Network Designer, I receive an error stating their are multiple observations. The x and y values are the same for different heights/temps/pressures from the same well. I am assuming this is were the issue arises, but I do not understand why the designer would produce a different error.
Example data (before transposing):
x y z T P
4407300 327880 2796 344.3 501
4407300 327880 2746 356.5 521
4407300 327880 2696 357 541
Where train_x would be the first 3 columns, and train_y is the last 2.
Full Code:
inputSize = 3;
hiddenLayerSize = 20;
outputSize = 2;
layers = [
featureInputLayer(inputSize)
fullyConnectedLayer(hiddenLayerSize, ‘Name’, ‘fc1’)
reluLayer(‘Name’, ‘relu1’)
fullyConnectedLayer(outputSize, ‘Name’, ‘output’)
];
net = dlnetwork(layers);
opts = trainingOptions(‘adam’, …
‘MaxEpochs’, 100, …
‘MiniBatchSize’, 64, …
‘ValidationData’, {val_x_array_transposed’, val_y_array_transposed’}, …
‘ValidationFrequency’, 10, …
‘Verbose’, true …
);
netTrained = trainnet(train_x_array_transposed, train_y_array_transposed, net,"mse", opts);
Y_pred_val = predict(netTrained, val_x_array’); deep network designer, neural network, multiple inputs and outputs MATLAB Answers — New Questions
If I set up the Hardware board in Hardware Implementation, can’t I turn ON the “Generate and example main program” setting in Templates?
Specific hardware was set in Configuration Parameter –> Hardware Implementation –> Hardware board.
Code Generation –> System target file was set to ert.tlc.
If you turn on "Generate an example main program" in Code Generation –> Templates –> Custom Templates,
<The ‘GenerateSampleERTMain’ model parameter is set to ‘on’, but your hardware board requires it to be set to ‘off’ . Use ‘set_param’ command to set the ‘GenerateSampleERTMain’ model parameter to ‘off.>" Error occurs.
If I set up the Hardware board in Hardware Implementation, can’t I turn ON the "Generate and example main program" setting in Templates?Specific hardware was set in Configuration Parameter –> Hardware Implementation –> Hardware board.
Code Generation –> System target file was set to ert.tlc.
If you turn on "Generate an example main program" in Code Generation –> Templates –> Custom Templates,
<The ‘GenerateSampleERTMain’ model parameter is set to ‘on’, but your hardware board requires it to be set to ‘off’ . Use ‘set_param’ command to set the ‘GenerateSampleERTMain’ model parameter to ‘off.>" Error occurs.
If I set up the Hardware board in Hardware Implementation, can’t I turn ON the "Generate and example main program" setting in Templates? Specific hardware was set in Configuration Parameter –> Hardware Implementation –> Hardware board.
Code Generation –> System target file was set to ert.tlc.
If you turn on "Generate an example main program" in Code Generation –> Templates –> Custom Templates,
<The ‘GenerateSampleERTMain’ model parameter is set to ‘on’, but your hardware board requires it to be set to ‘off’ . Use ‘set_param’ command to set the ‘GenerateSampleERTMain’ model parameter to ‘off.>" Error occurs.
If I set up the Hardware board in Hardware Implementation, can’t I turn ON the "Generate and example main program" setting in Templates? embedded coder, generate code, generatesampleertmain MATLAB Answers — New Questions
Class D amplifier simulation model with Asynchronous delta sigma modulation
Hello communitiy members,
I am trying to build a Class D amplifier simulation model, but I coundt run it. would you please me help with class d amplifier simulation model.
Thank You.Hello communitiy members,
I am trying to build a Class D amplifier simulation model, but I coundt run it. would you please me help with class d amplifier simulation model.
Thank You. Hello communitiy members,
I am trying to build a Class D amplifier simulation model, but I coundt run it. would you please me help with class d amplifier simulation model.
Thank You. class d amplfier, simulink MATLAB Answers — New Questions
Download file using “websave” from a source that requires login via Oauth
How can I download a file from NASA’s Archive of Space Geodesy Data at the provided URL, which requires login information and redirection? My current code attempts to download the file directly using websave, but it only retrieves the login page’s HTML instead.
https://urs.earthdata.nasa.gov/oauth/authorizeHow can I download a file from NASA’s Archive of Space Geodesy Data at the provided URL, which requires login information and redirection? My current code attempts to download the file directly using websave, but it only retrieves the login page’s HTML instead.
https://urs.earthdata.nasa.gov/oauth/authorize How can I download a file from NASA’s Archive of Space Geodesy Data at the provided URL, which requires login information and redirection? My current code attempts to download the file directly using websave, but it only retrieves the login page’s HTML instead.
https://urs.earthdata.nasa.gov/oauth/authorize auth, webread MATLAB Answers — New Questions
How to implement ESN layers or more generally reservoir computing approach in MATLAB DDPG agent
Hello,
Is it possible to use echo state neural networks and generally reservoir computing approach as actor and critic networks in matlab with DDPG agent? Does MATLAB support this feature? If yes, how to do it and also from what version of MATLAB is it supported and If no, how do you suggest to implement it manually?
(The main idea is to use reservoir computing approach to increase DDPG learning speed in continuous action-state space by only updating output layer of actor and critic networks.)
Any Suggestion ?Hello,
Is it possible to use echo state neural networks and generally reservoir computing approach as actor and critic networks in matlab with DDPG agent? Does MATLAB support this feature? If yes, how to do it and also from what version of MATLAB is it supported and If no, how do you suggest to implement it manually?
(The main idea is to use reservoir computing approach to increase DDPG learning speed in continuous action-state space by only updating output layer of actor and critic networks.)
Any Suggestion ? Hello,
Is it possible to use echo state neural networks and generally reservoir computing approach as actor and critic networks in matlab with DDPG agent? Does MATLAB support this feature? If yes, how to do it and also from what version of MATLAB is it supported and If no, how do you suggest to implement it manually?
(The main idea is to use reservoir computing approach to increase DDPG learning speed in continuous action-state space by only updating output layer of actor and critic networks.)
Any Suggestion ? neural networks, machine learning, reinforcement learning, ddpg, esn, reservoir computing MATLAB Answers — New Questions
what does the vertical line in the editor window mean?
I notice that in the editor window, there is a vertical ruler. What is the purpose of this vertical line?I notice that in the editor window, there is a vertical ruler. What is the purpose of this vertical line? I notice that in the editor window, there is a vertical ruler. What is the purpose of this vertical line? matlab coder MATLAB Answers — New Questions
Hybrid Battery-Ultracapacitor for EV
Conversion of example model of Fuel Cell Electric Vehicle (FCEV) Architecture into a Hybrid system of Battery-Ultracapacitor for Electric Vehicle application.Conversion of example model of Fuel Cell Electric Vehicle (FCEV) Architecture into a Hybrid system of Battery-Ultracapacitor for Electric Vehicle application. Conversion of example model of Fuel Cell Electric Vehicle (FCEV) Architecture into a Hybrid system of Battery-Ultracapacitor for Electric Vehicle application. battery-ultracapacitor, ultracapacitor, battery, battery-ultracapacitor for electric vehicle MATLAB Answers — New Questions
How do I define HANTS matlab parameters?
I am using HANTS MATLAB code for the NDVI time series. I have defined the parameters as follows;
function [yOut, amp, phi]=ApplyHants(y,nb,nf,fet,dod,HiLo,low,high,delta)
nb = 22 ; total number of images
nf = 3 frequency above zero frequency
fet = 5
dod = 5
HiLo = ‘none’
low = -1.0 ; minimum value of NDVI
high = 1.0 ; maximum value of NDVI
delta = 0.1
but it is giving output as zero values.
Please suggest me how to define these above mentioned parameters for my NDVI time series of one year time period having 22 images.
I would appreciate your kind help.
GauriI am using HANTS MATLAB code for the NDVI time series. I have defined the parameters as follows;
function [yOut, amp, phi]=ApplyHants(y,nb,nf,fet,dod,HiLo,low,high,delta)
nb = 22 ; total number of images
nf = 3 frequency above zero frequency
fet = 5
dod = 5
HiLo = ‘none’
low = -1.0 ; minimum value of NDVI
high = 1.0 ; maximum value of NDVI
delta = 0.1
but it is giving output as zero values.
Please suggest me how to define these above mentioned parameters for my NDVI time series of one year time period having 22 images.
I would appreciate your kind help.
Gauri I am using HANTS MATLAB code for the NDVI time series. I have defined the parameters as follows;
function [yOut, amp, phi]=ApplyHants(y,nb,nf,fet,dod,HiLo,low,high,delta)
nb = 22 ; total number of images
nf = 3 frequency above zero frequency
fet = 5
dod = 5
HiLo = ‘none’
low = -1.0 ; minimum value of NDVI
high = 1.0 ; maximum value of NDVI
delta = 0.1
but it is giving output as zero values.
Please suggest me how to define these above mentioned parameters for my NDVI time series of one year time period having 22 images.
I would appreciate your kind help.
Gauri how do i define hants matlab parameters? MATLAB Answers — New Questions
I am trying to plot a line but it is not working.
Kc = 1.08;
k = 9*10^(-5);
V0 = 200;
Ca0 = 7.72;
Fa0 = 0.05;
t = 1:1000;
Xe = ((Ca0*V0)-(Fa0*t))/((Ca0*V0)+((Kc-1)*(Fa0*t)));
plot(t, Xe)
xlabel(‘Time (s)’)
ylabel(‘Equilibrium Conversion of Ethyl Acetate’)
title(‘Equilibrium Conversion vs. Time’)
What is the issue? Thanks in advance.Kc = 1.08;
k = 9*10^(-5);
V0 = 200;
Ca0 = 7.72;
Fa0 = 0.05;
t = 1:1000;
Xe = ((Ca0*V0)-(Fa0*t))/((Ca0*V0)+((Kc-1)*(Fa0*t)));
plot(t, Xe)
xlabel(‘Time (s)’)
ylabel(‘Equilibrium Conversion of Ethyl Acetate’)
title(‘Equilibrium Conversion vs. Time’)
What is the issue? Thanks in advance. Kc = 1.08;
k = 9*10^(-5);
V0 = 200;
Ca0 = 7.72;
Fa0 = 0.05;
t = 1:1000;
Xe = ((Ca0*V0)-(Fa0*t))/((Ca0*V0)+((Kc-1)*(Fa0*t)));
plot(t, Xe)
xlabel(‘Time (s)’)
ylabel(‘Equilibrium Conversion of Ethyl Acetate’)
title(‘Equilibrium Conversion vs. Time’)
What is the issue? Thanks in advance. #plot MATLAB Answers — New Questions
Why is there an error in the calculation of 366.0/5.0?
I input the following code in Matlab and the result obtained has a small error, as shown below:
>> format long
>> 367/5
ans =
73.400000000000006I input the following code in Matlab and the result obtained has a small error, as shown below:
>> format long
>> 367/5
ans =
73.400000000000006 I input the following code in Matlab and the result obtained has a small error, as shown below:
>> format long
>> 367/5
ans =
73.400000000000006 数值计算 MATLAB Answers — New Questions
How to stop further execution of M-script by using command?
Hello.
I’m trying to use ‘questdlg’ to shows question dialog with several buttons. My aim is that when I click ‘stop’ button in the dialog generated by using ‘questdlg’, no further execution of code.’switch’ is used to define each action of buttons right after ‘questdlg’.
I’m using break and return and they’re all just to get out of the ‘switch’. How can I abort all code running by using command?Hello.
I’m trying to use ‘questdlg’ to shows question dialog with several buttons. My aim is that when I click ‘stop’ button in the dialog generated by using ‘questdlg’, no further execution of code.’switch’ is used to define each action of buttons right after ‘questdlg’.
I’m using break and return and they’re all just to get out of the ‘switch’. How can I abort all code running by using command? Hello.
I’m trying to use ‘questdlg’ to shows question dialog with several buttons. My aim is that when I click ‘stop’ button in the dialog generated by using ‘questdlg’, no further execution of code.’switch’ is used to define each action of buttons right after ‘questdlg’.
I’m using break and return and they’re all just to get out of the ‘switch’. How can I abort all code running by using command? termination, abort MATLAB Answers — New Questions
How does MATLAB downsample the output of the linear equalizer in a fractional comm.LinearEqualizer?
The documentation for the comm.LinearEqualizer explains that for fractionally spaced equalizers, where the sample rate of the input to the equalizer is an integer multiple of the symbol rate, the output of the equalizer has one sample per symbol. This seems to indicate that the equalizer is performing some sort of downsampling. How does this work?
If I take the final equalizer tap weights ("weights") and convolve them with the input to the equalizer, which is called "Data":
eq = comm.LinearEqualizer;
[FFEout,~,weights] = step(eq,Data,TrainingSequence);
FIRout = conv(Data,conj(weights),’same’);
I would expect the output of the convolution to be equal to an interpolated (upsampled). In other words, "FFEout" should be a downsampled version of "FIRout". However, this is not the case, as can be seen in the below plot; the signal is QPSK modulated, so the exact values for the I and Q channels are either +1 or -1.
The plot shows that the equalizer is working as expected (FFEout lines up nicely with the exact data). However, the fact that convolving the signal with the filter tap weights does not seem to correspond to the output of the equalizer has me confused, since the equalizer is just performing a convolution with optimized tap weights. Does MATLAB do something fancier than simple downsampling to obtain the output symbols from the equalizer?The documentation for the comm.LinearEqualizer explains that for fractionally spaced equalizers, where the sample rate of the input to the equalizer is an integer multiple of the symbol rate, the output of the equalizer has one sample per symbol. This seems to indicate that the equalizer is performing some sort of downsampling. How does this work?
If I take the final equalizer tap weights ("weights") and convolve them with the input to the equalizer, which is called "Data":
eq = comm.LinearEqualizer;
[FFEout,~,weights] = step(eq,Data,TrainingSequence);
FIRout = conv(Data,conj(weights),’same’);
I would expect the output of the convolution to be equal to an interpolated (upsampled). In other words, "FFEout" should be a downsampled version of "FIRout". However, this is not the case, as can be seen in the below plot; the signal is QPSK modulated, so the exact values for the I and Q channels are either +1 or -1.
The plot shows that the equalizer is working as expected (FFEout lines up nicely with the exact data). However, the fact that convolving the signal with the filter tap weights does not seem to correspond to the output of the equalizer has me confused, since the equalizer is just performing a convolution with optimized tap weights. Does MATLAB do something fancier than simple downsampling to obtain the output symbols from the equalizer? The documentation for the comm.LinearEqualizer explains that for fractionally spaced equalizers, where the sample rate of the input to the equalizer is an integer multiple of the symbol rate, the output of the equalizer has one sample per symbol. This seems to indicate that the equalizer is performing some sort of downsampling. How does this work?
If I take the final equalizer tap weights ("weights") and convolve them with the input to the equalizer, which is called "Data":
eq = comm.LinearEqualizer;
[FFEout,~,weights] = step(eq,Data,TrainingSequence);
FIRout = conv(Data,conj(weights),’same’);
I would expect the output of the convolution to be equal to an interpolated (upsampled). In other words, "FFEout" should be a downsampled version of "FIRout". However, this is not the case, as can be seen in the below plot; the signal is QPSK modulated, so the exact values for the I and Q channels are either +1 or -1.
The plot shows that the equalizer is working as expected (FFEout lines up nicely with the exact data). However, the fact that convolving the signal with the filter tap weights does not seem to correspond to the output of the equalizer has me confused, since the equalizer is just performing a convolution with optimized tap weights. Does MATLAB do something fancier than simple downsampling to obtain the output symbols from the equalizer? equalizer, matlab, tap weights, fractionally spaced MATLAB Answers — New Questions
How to convert table variable to datetime and adjust timezone?
Hi there! I have a table that reads a csv file for which column A is "Time" and is in posix-millisec format. I would like to convert the values to dd-mm-yyyy format and then convert values into the time zone which the data were taken. I would like these newly formatted versions of the values to replace the originals in my table. Here is what I have put together so far.
My Table is name "T":
The following line works fine and the resultant dates are at UTC time:
T.Time = datetime(T.Time,’ConvertFrom’,’epochtime’,’TicksPerSecond’,1e3,’Format’,’dd-MMM-yyyy HH:mm:ss.SSS’)
The following line appears to work, but I am not sure how to check, and I think tells Matlab that the table variable Time is in UTC timezone so that it can be converted with subsequent commands.
T.Time = datetime(T.Time, "TimeZone","UTC")
This is where I get lost: How can I convert all of the values in T.Time to be in ‘America/New_York’ timezone so that when I plot T.Time vs <Stuff> my time axis reads in New York time?
I tried the following but it throws an error "Error using . To assign to or create a variable in a table, the number of rows must match the height of the table."
T.Time = ‘America/New_York’
Thank you!Hi there! I have a table that reads a csv file for which column A is "Time" and is in posix-millisec format. I would like to convert the values to dd-mm-yyyy format and then convert values into the time zone which the data were taken. I would like these newly formatted versions of the values to replace the originals in my table. Here is what I have put together so far.
My Table is name "T":
The following line works fine and the resultant dates are at UTC time:
T.Time = datetime(T.Time,’ConvertFrom’,’epochtime’,’TicksPerSecond’,1e3,’Format’,’dd-MMM-yyyy HH:mm:ss.SSS’)
The following line appears to work, but I am not sure how to check, and I think tells Matlab that the table variable Time is in UTC timezone so that it can be converted with subsequent commands.
T.Time = datetime(T.Time, "TimeZone","UTC")
This is where I get lost: How can I convert all of the values in T.Time to be in ‘America/New_York’ timezone so that when I plot T.Time vs <Stuff> my time axis reads in New York time?
I tried the following but it throws an error "Error using . To assign to or create a variable in a table, the number of rows must match the height of the table."
T.Time = ‘America/New_York’
Thank you! Hi there! I have a table that reads a csv file for which column A is "Time" and is in posix-millisec format. I would like to convert the values to dd-mm-yyyy format and then convert values into the time zone which the data were taken. I would like these newly formatted versions of the values to replace the originals in my table. Here is what I have put together so far.
My Table is name "T":
The following line works fine and the resultant dates are at UTC time:
T.Time = datetime(T.Time,’ConvertFrom’,’epochtime’,’TicksPerSecond’,1e3,’Format’,’dd-MMM-yyyy HH:mm:ss.SSS’)
The following line appears to work, but I am not sure how to check, and I think tells Matlab that the table variable Time is in UTC timezone so that it can be converted with subsequent commands.
T.Time = datetime(T.Time, "TimeZone","UTC")
This is where I get lost: How can I convert all of the values in T.Time to be in ‘America/New_York’ timezone so that when I plot T.Time vs <Stuff> my time axis reads in New York time?
I tried the following but it throws an error "Error using . To assign to or create a variable in a table, the number of rows must match the height of the table."
T.Time = ‘America/New_York’
Thank you! datetime, table, time zone MATLAB Answers — New Questions