Tag Archives: matlab
correct for these codes and help me to get running codes
% System parameters
M = 50; % Number of antennas
K = 3; % Number of terminals
SNR_dB = 20; % SNR in dB
numSymbols = 1e4; % Number of symbols for simulation
L_prime = 5; % L’ = 5
% QPSK Modulator and Demodulator
qpskMod = comm.QPSKModulator(‘BitInput’, false);
qpskDemod = comm.QPSKDemodulator(‘BitOutput’, false);
% Generate random data symbols
dataSymbols = randi([0 3], K, numSymbols);
% Generate transmitted symbols (QPSK)
txSymbols = step(qpskMod, dataSymbols(:)); % Corrected input format
txSymbols = reshape(txSymbols, [], K);
% Channel matrix
H = (randn(M, K) + 1i*randn(M, K))/sqrt(2);
% Received signal with AWGN
rxSignal = awgn(H .* txSymbols, SNR_dB, ‘measured’); % Transpose to match dimensions
% MRC Combining
combiner_MRC = conj(H);
rxCombined_MRC = combiner_MRC * rxSignal;
% ZF Combining
combiner_ZF = pinv(H);
rxCombined_ZF = combiner_ZF * rxSignal;
% Demodulate received symbols
rxDataSymbols_MRC = step(qpskDemod, rxCombined_MRC(:));
rxDataSymbols_ZF = step(qpskDemod, rxCombined_ZF(:));
% Decision threshold (for QPSK, it’s zero)
detected_MRC = rxDataSymbols_MRC > 0;
detected_ZF = rxDataSymbols_ZF > 0;
% Reshape for plotting
rxCombined_MRC = reshape(rxCombined_MRC, [], 1);
rxCombined_ZF = reshape(rxCombined_ZF, [], 1);
% Plotting
figure;
subplot(1, 2, 1);
scatterplot(rxCombined_MRC);
title(‘MRC Receiver’);
xlabel(‘In-Phase’);
ylabel(‘Quadrature’);
axis equal; % Equal scaling on both axes
grid on;
subplot(1, 2, 2);
scatterplot(rxCombined_ZF);
title(‘ZF Receiver’);
xlabel(‘In-Phase’);
ylabel(‘Quadrature’);
axis equal; % Equal scaling on both axes
grid on;
sgtitle(‘Constellation of Estimated Symbols for K=3, M=50, L”=5, and rho=20 dB’);% System parameters
M = 50; % Number of antennas
K = 3; % Number of terminals
SNR_dB = 20; % SNR in dB
numSymbols = 1e4; % Number of symbols for simulation
L_prime = 5; % L’ = 5
% QPSK Modulator and Demodulator
qpskMod = comm.QPSKModulator(‘BitInput’, false);
qpskDemod = comm.QPSKDemodulator(‘BitOutput’, false);
% Generate random data symbols
dataSymbols = randi([0 3], K, numSymbols);
% Generate transmitted symbols (QPSK)
txSymbols = step(qpskMod, dataSymbols(:)); % Corrected input format
txSymbols = reshape(txSymbols, [], K);
% Channel matrix
H = (randn(M, K) + 1i*randn(M, K))/sqrt(2);
% Received signal with AWGN
rxSignal = awgn(H .* txSymbols, SNR_dB, ‘measured’); % Transpose to match dimensions
% MRC Combining
combiner_MRC = conj(H);
rxCombined_MRC = combiner_MRC * rxSignal;
% ZF Combining
combiner_ZF = pinv(H);
rxCombined_ZF = combiner_ZF * rxSignal;
% Demodulate received symbols
rxDataSymbols_MRC = step(qpskDemod, rxCombined_MRC(:));
rxDataSymbols_ZF = step(qpskDemod, rxCombined_ZF(:));
% Decision threshold (for QPSK, it’s zero)
detected_MRC = rxDataSymbols_MRC > 0;
detected_ZF = rxDataSymbols_ZF > 0;
% Reshape for plotting
rxCombined_MRC = reshape(rxCombined_MRC, [], 1);
rxCombined_ZF = reshape(rxCombined_ZF, [], 1);
% Plotting
figure;
subplot(1, 2, 1);
scatterplot(rxCombined_MRC);
title(‘MRC Receiver’);
xlabel(‘In-Phase’);
ylabel(‘Quadrature’);
axis equal; % Equal scaling on both axes
grid on;
subplot(1, 2, 2);
scatterplot(rxCombined_ZF);
title(‘ZF Receiver’);
xlabel(‘In-Phase’);
ylabel(‘Quadrature’);
axis equal; % Equal scaling on both axes
grid on;
sgtitle(‘Constellation of Estimated Symbols for K=3, M=50, L”=5, and rho=20 dB’); % System parameters
M = 50; % Number of antennas
K = 3; % Number of terminals
SNR_dB = 20; % SNR in dB
numSymbols = 1e4; % Number of symbols for simulation
L_prime = 5; % L’ = 5
% QPSK Modulator and Demodulator
qpskMod = comm.QPSKModulator(‘BitInput’, false);
qpskDemod = comm.QPSKDemodulator(‘BitOutput’, false);
% Generate random data symbols
dataSymbols = randi([0 3], K, numSymbols);
% Generate transmitted symbols (QPSK)
txSymbols = step(qpskMod, dataSymbols(:)); % Corrected input format
txSymbols = reshape(txSymbols, [], K);
% Channel matrix
H = (randn(M, K) + 1i*randn(M, K))/sqrt(2);
% Received signal with AWGN
rxSignal = awgn(H .* txSymbols, SNR_dB, ‘measured’); % Transpose to match dimensions
% MRC Combining
combiner_MRC = conj(H);
rxCombined_MRC = combiner_MRC * rxSignal;
% ZF Combining
combiner_ZF = pinv(H);
rxCombined_ZF = combiner_ZF * rxSignal;
% Demodulate received symbols
rxDataSymbols_MRC = step(qpskDemod, rxCombined_MRC(:));
rxDataSymbols_ZF = step(qpskDemod, rxCombined_ZF(:));
% Decision threshold (for QPSK, it’s zero)
detected_MRC = rxDataSymbols_MRC > 0;
detected_ZF = rxDataSymbols_ZF > 0;
% Reshape for plotting
rxCombined_MRC = reshape(rxCombined_MRC, [], 1);
rxCombined_ZF = reshape(rxCombined_ZF, [], 1);
% Plotting
figure;
subplot(1, 2, 1);
scatterplot(rxCombined_MRC);
title(‘MRC Receiver’);
xlabel(‘In-Phase’);
ylabel(‘Quadrature’);
axis equal; % Equal scaling on both axes
grid on;
subplot(1, 2, 2);
scatterplot(rxCombined_ZF);
title(‘ZF Receiver’);
xlabel(‘In-Phase’);
ylabel(‘Quadrature’);
axis equal; % Equal scaling on both axes
grid on;
sgtitle(‘Constellation of Estimated Symbols for K=3, M=50, L”=5, and rho=20 dB’); correct for these codes and help me to get running MATLAB Answers — New Questions
Simulink merge bus failure
1, during smilulink model based developing case : there were two bus whcih need merge into one bus , with simulation ,both input of merge block was bus , error was report that the output of merge block was not a bus signal1, during smilulink model based developing case : there were two bus whcih need merge into one bus , with simulation ,both input of merge block was bus , error was report that the output of merge block was not a bus signal 1, during smilulink model based developing case : there were two bus whcih need merge into one bus , with simulation ,both input of merge block was bus , error was report that the output of merge block was not a bus signal simulink, merge, bus, error MATLAB Answers — New Questions
yolov2layers, featurelayer and reorglayer
Just been working on yolov2Layers, and I’ve noticed that in both the help page on yolov2layers and the deep learning onramp courses, the featurelayer is relulayer after the reorglayer. Does the featurelayer always have to be after the reorglayer and what exactly is the point of the reorglayer?Just been working on yolov2Layers, and I’ve noticed that in both the help page on yolov2layers and the deep learning onramp courses, the featurelayer is relulayer after the reorglayer. Does the featurelayer always have to be after the reorglayer and what exactly is the point of the reorglayer? Just been working on yolov2Layers, and I’ve noticed that in both the help page on yolov2layers and the deep learning onramp courses, the featurelayer is relulayer after the reorglayer. Does the featurelayer always have to be after the reorglayer and what exactly is the point of the reorglayer? yolov2layers MATLAB Answers — New Questions
How can I merge the sine wave?
there are space (200, 200, 20), and sensor that move (100, 1~200, 20).
I want to scan topographic features with sensor.
I know the distance from each sensor’s location to the row coordinates of the sensor and the terrain, and the round-trip time via the speed of sound underwater (1500 m/s).
At this point, I want to scan the terrain by shooting a sine wave from each sensor’s position toward a point.
I can get each sine wave, but I can’t seem to get it to sum over rows, so I ask this question.
Below is the code I currently have written, but I think it’s wrong
Fs = 10000; % sampling F
time_step = 1 / Fs;
max_time = max(L_values(:));%left side time value
t = 0:time_step:max_time;
combined_pulse_data = zeros(gridSize, length(t));
% generate sine wave and combine
for i = 1:100
for j = 1:gridSize
pulse_time = L_values(i, j);
if pulse_time > 0
pulse_index = round(pulse_time / time_step);
if pulse_index > 0 && pulse_index <= length(t)
combined_pulse_data(i, pulse_index:end) = combined_pulse_data(i, pulse_index:end) +
sin(2 * pi * 1000 * t(1:end-pulse_index+1));
end
end
end
endthere are space (200, 200, 20), and sensor that move (100, 1~200, 20).
I want to scan topographic features with sensor.
I know the distance from each sensor’s location to the row coordinates of the sensor and the terrain, and the round-trip time via the speed of sound underwater (1500 m/s).
At this point, I want to scan the terrain by shooting a sine wave from each sensor’s position toward a point.
I can get each sine wave, but I can’t seem to get it to sum over rows, so I ask this question.
Below is the code I currently have written, but I think it’s wrong
Fs = 10000; % sampling F
time_step = 1 / Fs;
max_time = max(L_values(:));%left side time value
t = 0:time_step:max_time;
combined_pulse_data = zeros(gridSize, length(t));
% generate sine wave and combine
for i = 1:100
for j = 1:gridSize
pulse_time = L_values(i, j);
if pulse_time > 0
pulse_index = round(pulse_time / time_step);
if pulse_index > 0 && pulse_index <= length(t)
combined_pulse_data(i, pulse_index:end) = combined_pulse_data(i, pulse_index:end) +
sin(2 * pi * 1000 * t(1:end-pulse_index+1));
end
end
end
end there are space (200, 200, 20), and sensor that move (100, 1~200, 20).
I want to scan topographic features with sensor.
I know the distance from each sensor’s location to the row coordinates of the sensor and the terrain, and the round-trip time via the speed of sound underwater (1500 m/s).
At this point, I want to scan the terrain by shooting a sine wave from each sensor’s position toward a point.
I can get each sine wave, but I can’t seem to get it to sum over rows, so I ask this question.
Below is the code I currently have written, but I think it’s wrong
Fs = 10000; % sampling F
time_step = 1 / Fs;
max_time = max(L_values(:));%left side time value
t = 0:time_step:max_time;
combined_pulse_data = zeros(gridSize, length(t));
% generate sine wave and combine
for i = 1:100
for j = 1:gridSize
pulse_time = L_values(i, j);
if pulse_time > 0
pulse_index = round(pulse_time / time_step);
if pulse_index > 0 && pulse_index <= length(t)
combined_pulse_data(i, pulse_index:end) = combined_pulse_data(i, pulse_index:end) +
sin(2 * pi * 1000 * t(1:end-pulse_index+1));
end
end
end
end sine, sine wave, sum signal, combine signal MATLAB Answers — New Questions
WorkSpace space and ModelSpace, Sldd Design Data space, and function workspace, they can store different content, what is the difference?
WorkSpace space and ModelSpace, Sldd Design Data space, and function workspace, they can store different content, what is the difference?WorkSpace space and ModelSpace, Sldd Design Data space, and function workspace, they can store different content, what is the difference? WorkSpace space and ModelSpace, Sldd Design Data space, and function workspace, they can store different content, what is the difference? workspace, model, sldd MATLAB Answers — New Questions
GPU memory usage for Hadamard product
I have a GPU with 48 Gb of RAM.
I have a large matrix A (complex single 45927×45927, gpuArray) taking 16 Gb of my GPU.
I get to the following Hadamard product with a vector B (complex single 45927×1, gpuArray) with approximately 28 Gb of free RAM on the GPU:
C = A .* (B.’)
But this throws an "out of memory on the device" error, despite there being enough memory for C (also 16 Gb). Why is this happening? Does MATLAB implicitly convert B to a full matrix? Is there a way to get this multiplication to work on the GPU within the available memory? (maybe this has been fixed in later releases of MATLAB?)I have a GPU with 48 Gb of RAM.
I have a large matrix A (complex single 45927×45927, gpuArray) taking 16 Gb of my GPU.
I get to the following Hadamard product with a vector B (complex single 45927×1, gpuArray) with approximately 28 Gb of free RAM on the GPU:
C = A .* (B.’)
But this throws an "out of memory on the device" error, despite there being enough memory for C (also 16 Gb). Why is this happening? Does MATLAB implicitly convert B to a full matrix? Is there a way to get this multiplication to work on the GPU within the available memory? (maybe this has been fixed in later releases of MATLAB?) I have a GPU with 48 Gb of RAM.
I have a large matrix A (complex single 45927×45927, gpuArray) taking 16 Gb of my GPU.
I get to the following Hadamard product with a vector B (complex single 45927×1, gpuArray) with approximately 28 Gb of free RAM on the GPU:
C = A .* (B.’)
But this throws an "out of memory on the device" error, despite there being enough memory for C (also 16 Gb). Why is this happening? Does MATLAB implicitly convert B to a full matrix? Is there a way to get this multiplication to work on the GPU within the available memory? (maybe this has been fixed in later releases of MATLAB?) hadamard, gpu, memory, product MATLAB Answers — New Questions
ROS2 Toolbox error when I try to add custom service/message
Hi Guys,
I have been facing this problem for some days when I try to change the parameters of the ROS2 blocks
Error: ros.slros2.internal.block.ServiceCallBlockMask.dispatch(‘serviceEdit’,gcb) caused by: cell array input must be a cell array of character vectors
OS version: Ubuntu 22.04
Matlab version: 23.2.0.2599560 (R2023b) Update 8Hi Guys,
I have been facing this problem for some days when I try to change the parameters of the ROS2 blocks
Error: ros.slros2.internal.block.ServiceCallBlockMask.dispatch(‘serviceEdit’,gcb) caused by: cell array input must be a cell array of character vectors
OS version: Ubuntu 22.04
Matlab version: 23.2.0.2599560 (R2023b) Update 8 Hi Guys,
I have been facing this problem for some days when I try to change the parameters of the ROS2 blocks
Error: ros.slros2.internal.block.ServiceCallBlockMask.dispatch(‘serviceEdit’,gcb) caused by: cell array input must be a cell array of character vectors
OS version: Ubuntu 22.04
Matlab version: 23.2.0.2599560 (R2023b) Update 8 matlab, ros, simulink, error MATLAB Answers — New Questions
write a MATLAB code to locate all yellow circles in the provided image
https://www.mathworks.com/help/images/detect-and-measure-circular-objects-in-an-image.html
Detect and Measure Circular Objects in an Image – MATLAB & Simulink
Automatically detect circular objects in an image and visualize the detected circles.
www.mathworks.com
Steps are here, just detect all the yellow circles in the imagehttps://www.mathworks.com/help/images/detect-and-measure-circular-objects-in-an-image.html
Detect and Measure Circular Objects in an Image – MATLAB & Simulink
Automatically detect circular objects in an image and visualize the detected circles.
www.mathworks.com
Steps are here, just detect all the yellow circles in the image https://www.mathworks.com/help/images/detect-and-measure-circular-objects-in-an-image.html
Detect and Measure Circular Objects in an Image – MATLAB & Simulink
Automatically detect circular objects in an image and visualize the detected circles.
www.mathworks.com
Steps are here, just detect all the yellow circles in the image image processing MATLAB Answers — New Questions
Error with ROS toolbox to create a my own toolbox
Hi guys,
I was trying to create a my own toolbox with a custom simulink library but I found this error during the procedure "package a toolbox". Is there anyone can help me to find a workaround?
OS version: Ubuntu 22.04
Matlab version: 2023bHi guys,
I was trying to create a my own toolbox with a custom simulink library but I found this error during the procedure "package a toolbox". Is there anyone can help me to find a workaround?
OS version: Ubuntu 22.04
Matlab version: 2023b Hi guys,
I was trying to create a my own toolbox with a custom simulink library but I found this error during the procedure "package a toolbox". Is there anyone can help me to find a workaround?
OS version: Ubuntu 22.04
Matlab version: 2023b simulink, error, toolbox, ros MATLAB Answers — New Questions
Image Classification Training Issue
The following error comes while executing the image classification task.
augementedImageDatastore cannot form minibatches of data because the input image sizes differ in the 3rd dimension.Consider using color preprocessing to ensure all augmented images have same no of channels.The following error comes while executing the image classification task.
augementedImageDatastore cannot form minibatches of data because the input image sizes differ in the 3rd dimension.Consider using color preprocessing to ensure all augmented images have same no of channels. The following error comes while executing the image classification task.
augementedImageDatastore cannot form minibatches of data because the input image sizes differ in the 3rd dimension.Consider using color preprocessing to ensure all augmented images have same no of channels. image classification, augmented images channel size MATLAB Answers — New Questions
I cannot read data from sci-tx port(Serial communication)
Part Number: TMS320F280025C
Other Parts Discussed in Thread: LAUNCHXL-F280025C, C2000WARE
I have a simulink model for a power electronics project and i want to see detailed data using SCI-TX port in simulink. For this, i have created 2 codes, one is for code generation and the other one is for watching the data. Both of the codes work without a problem in LAUNCHXL-F280025C. The default pins are GPIO28 and GPIO29 for TX and RX, and when i want to change these pins, using the hardware switch at the launchpad also creates no problem and i am able to also use GPIO16 and GPIO17 pins. Hovewer, using the TMS320F280025CPNSR (this processor is used in my project card), i cannot get the data interface to work in any ways. The pins are selected as GPIO16 and GPIO17 in project card. In summary, with the launchpad, i am able to see the data on sci pins, but the same codes do not work for the control card (i change the build configurations to TI F28002x.) I have tried lots of methods, i tried GPIO2 and GPIO3 pins instead, didnt work. I even tried to change the value for OUTPUTXBAR7 to SCI-TX(6) but this didnt work either. Even this simple code where i read adc values and send it to serial pin does not send any data to my SCI-TX pin.(The codes themselves work but i do not see any data in model.) The only difference is that the FTDI we use is XDS100, but i have seen this card being used without any problem in other projects ( for example 49c.) The pins do not have a physical connection problem, as we tested them with a multimeter. I ran the sample sci code and my normal code on controlcard. The signals without noise came from controlcard, and i was able to see these signals using the TX pin on hardware.(GPIO16) Hovewer, it seems that the data is not being sent to pc, as i was not able to see any data in my interface model and putty application. The signal with noise comes from launchpad, but i am able to correctly read the data from my interface model. I dont have any ideas left, any suggestions?Part Number: TMS320F280025C
Other Parts Discussed in Thread: LAUNCHXL-F280025C, C2000WARE
I have a simulink model for a power electronics project and i want to see detailed data using SCI-TX port in simulink. For this, i have created 2 codes, one is for code generation and the other one is for watching the data. Both of the codes work without a problem in LAUNCHXL-F280025C. The default pins are GPIO28 and GPIO29 for TX and RX, and when i want to change these pins, using the hardware switch at the launchpad also creates no problem and i am able to also use GPIO16 and GPIO17 pins. Hovewer, using the TMS320F280025CPNSR (this processor is used in my project card), i cannot get the data interface to work in any ways. The pins are selected as GPIO16 and GPIO17 in project card. In summary, with the launchpad, i am able to see the data on sci pins, but the same codes do not work for the control card (i change the build configurations to TI F28002x.) I have tried lots of methods, i tried GPIO2 and GPIO3 pins instead, didnt work. I even tried to change the value for OUTPUTXBAR7 to SCI-TX(6) but this didnt work either. Even this simple code where i read adc values and send it to serial pin does not send any data to my SCI-TX pin.(The codes themselves work but i do not see any data in model.) The only difference is that the FTDI we use is XDS100, but i have seen this card being used without any problem in other projects ( for example 49c.) The pins do not have a physical connection problem, as we tested them with a multimeter. I ran the sample sci code and my normal code on controlcard. The signals without noise came from controlcard, and i was able to see these signals using the TX pin on hardware.(GPIO16) Hovewer, it seems that the data is not being sent to pc, as i was not able to see any data in my interface model and putty application. The signal with noise comes from launchpad, but i am able to correctly read the data from my interface model. I dont have any ideas left, any suggestions? Part Number: TMS320F280025C
Other Parts Discussed in Thread: LAUNCHXL-F280025C, C2000WARE
I have a simulink model for a power electronics project and i want to see detailed data using SCI-TX port in simulink. For this, i have created 2 codes, one is for code generation and the other one is for watching the data. Both of the codes work without a problem in LAUNCHXL-F280025C. The default pins are GPIO28 and GPIO29 for TX and RX, and when i want to change these pins, using the hardware switch at the launchpad also creates no problem and i am able to also use GPIO16 and GPIO17 pins. Hovewer, using the TMS320F280025CPNSR (this processor is used in my project card), i cannot get the data interface to work in any ways. The pins are selected as GPIO16 and GPIO17 in project card. In summary, with the launchpad, i am able to see the data on sci pins, but the same codes do not work for the control card (i change the build configurations to TI F28002x.) I have tried lots of methods, i tried GPIO2 and GPIO3 pins instead, didnt work. I even tried to change the value for OUTPUTXBAR7 to SCI-TX(6) but this didnt work either. Even this simple code where i read adc values and send it to serial pin does not send any data to my SCI-TX pin.(The codes themselves work but i do not see any data in model.) The only difference is that the FTDI we use is XDS100, but i have seen this card being used without any problem in other projects ( for example 49c.) The pins do not have a physical connection problem, as we tested them with a multimeter. I ran the sample sci code and my normal code on controlcard. The signals without noise came from controlcard, and i was able to see these signals using the TX pin on hardware.(GPIO16) Hovewer, it seems that the data is not being sent to pc, as i was not able to see any data in my interface model and putty application. The signal with noise comes from launchpad, but i am able to correctly read the data from my interface model. I dont have any ideas left, any suggestions? c2000, tx, rx, sci, serial, serial interface, interface, communication, texas instrument, controlcard, serial communication MATLAB Answers — New Questions
Resize columns automatically in PDF report
I am generating a PDF report from a matlab table in a “FormalTable” style but the coloumns width does not get resized automatically. I tried to use the class “mlreportgen.dom.ResizeToFitContents” to resize the columns of a table. But this doesn’t work with the PDF document reports. Any help here would be appreciated.I am generating a PDF report from a matlab table in a “FormalTable” style but the coloumns width does not get resized automatically. I tried to use the class “mlreportgen.dom.ResizeToFitContents” to resize the columns of a table. But this doesn’t work with the PDF document reports. Any help here would be appreciated. I am generating a PDF report from a matlab table in a “FormalTable” style but the coloumns width does not get resized automatically. I tried to use the class “mlreportgen.dom.ResizeToFitContents” to resize the columns of a table. But this doesn’t work with the PDF document reports. Any help here would be appreciated. matlab, reportgen, matlab report, pdf MATLAB Answers — New Questions
How can I install the ISO file for offline using documentation?
Hi,
I want to use MATLAB2024a documentation when i’m offline. I downloaded the ISO file for windows. I copy it to my PC, But unfortunately i can’t intall it on my PC. It does not contain setup.exe, please guide me.
Thanks for your considerations.Hi,
I want to use MATLAB2024a documentation when i’m offline. I downloaded the ISO file for windows. I copy it to my PC, But unfortunately i can’t intall it on my PC. It does not contain setup.exe, please guide me.
Thanks for your considerations. Hi,
I want to use MATLAB2024a documentation when i’m offline. I downloaded the ISO file for windows. I copy it to my PC, But unfortunately i can’t intall it on my PC. It does not contain setup.exe, please guide me.
Thanks for your considerations. documentaion, matlab, iso MATLAB Answers — New Questions
Workaround to Goto problems in Enabled Subsystems
Hello MATLAB Community,
I’m currently working on a Simulink model that includes a Powergui block set to EquivalentMode2 and a Current Measurement block. I need to use an Enabled Subsystem to manage part of my model, but I’m encountering issues with dynamically created Goto blocks when converting the subsystem.
Problem Description:
Setup:
My model includes a Controlled Voltage Source (in AC mode) and a Current Measurement block.
These blocks are part of a larger subsystem that needs to be enabled and disabled based on specific conditions.
Issue:
When I convert the subsystem to an Enabled Subsystem, Simulink dynamically creates Goto blocks within the Powergui’s EquivalentMode2 block, specifically inside the Current Measurement block.
This results in an error: Goto/From connections cannot cross nonvirtual subsystem boundaries.
Steps I’ve Taken:
I tried to manage the Current Measurement using standard Simulink blocks and physical signal converters but encountered issues with solver requirements.In other words, I cant add more complexity to an already fairly complex model, it would take forever.
I also attempted to create custom measurement logic but faced difficulties with integrating it seamlessly into the existing physical simulation. Again, here whatever I do requires a Solver and it turns it unfeasible to run (takes forever).
Error message I got:
Multiple Gotos found with tag named ‘DOC’
Component:Simulink | Category:Model error
First offending Goto ‘integrated_bat_fuel_2/powergui/EquivalentModel2/Yout/Goto2’
Component:Simulink | Category:Model error
Second offending Goto ‘integrated_bat_fuel_2/FuelCell Subsystem/FuelCell 1 kW 24V DC/Fuel Cell Stack/Current Measurement1/source’
Component:Simulink | Category:Model error
Additional Context:
I’m using Simulink with a combination of Simscape Electrical components.
The model involves a mix of physical and Simulink signals, making it critical to maintain compatibility across different simulation domains.
Any guidance or recommendations would be greatly appreciated!
Thank you, [Your Name]
Feel free to modify the draft as needed to better fit your situation or to add any other relevant details.
4o
Any ideas? Please advice , I already ran out of ideas and I have no clue on how to solve this, any guidance or recommendations would be greatly appreciated!
Thank you,
RaulHello MATLAB Community,
I’m currently working on a Simulink model that includes a Powergui block set to EquivalentMode2 and a Current Measurement block. I need to use an Enabled Subsystem to manage part of my model, but I’m encountering issues with dynamically created Goto blocks when converting the subsystem.
Problem Description:
Setup:
My model includes a Controlled Voltage Source (in AC mode) and a Current Measurement block.
These blocks are part of a larger subsystem that needs to be enabled and disabled based on specific conditions.
Issue:
When I convert the subsystem to an Enabled Subsystem, Simulink dynamically creates Goto blocks within the Powergui’s EquivalentMode2 block, specifically inside the Current Measurement block.
This results in an error: Goto/From connections cannot cross nonvirtual subsystem boundaries.
Steps I’ve Taken:
I tried to manage the Current Measurement using standard Simulink blocks and physical signal converters but encountered issues with solver requirements.In other words, I cant add more complexity to an already fairly complex model, it would take forever.
I also attempted to create custom measurement logic but faced difficulties with integrating it seamlessly into the existing physical simulation. Again, here whatever I do requires a Solver and it turns it unfeasible to run (takes forever).
Error message I got:
Multiple Gotos found with tag named ‘DOC’
Component:Simulink | Category:Model error
First offending Goto ‘integrated_bat_fuel_2/powergui/EquivalentModel2/Yout/Goto2’
Component:Simulink | Category:Model error
Second offending Goto ‘integrated_bat_fuel_2/FuelCell Subsystem/FuelCell 1 kW 24V DC/Fuel Cell Stack/Current Measurement1/source’
Component:Simulink | Category:Model error
Additional Context:
I’m using Simulink with a combination of Simscape Electrical components.
The model involves a mix of physical and Simulink signals, making it critical to maintain compatibility across different simulation domains.
Any guidance or recommendations would be greatly appreciated!
Thank you, [Your Name]
Feel free to modify the draft as needed to better fit your situation or to add any other relevant details.
4o
Any ideas? Please advice , I already ran out of ideas and I have no clue on how to solve this, any guidance or recommendations would be greatly appreciated!
Thank you,
Raul Hello MATLAB Community,
I’m currently working on a Simulink model that includes a Powergui block set to EquivalentMode2 and a Current Measurement block. I need to use an Enabled Subsystem to manage part of my model, but I’m encountering issues with dynamically created Goto blocks when converting the subsystem.
Problem Description:
Setup:
My model includes a Controlled Voltage Source (in AC mode) and a Current Measurement block.
These blocks are part of a larger subsystem that needs to be enabled and disabled based on specific conditions.
Issue:
When I convert the subsystem to an Enabled Subsystem, Simulink dynamically creates Goto blocks within the Powergui’s EquivalentMode2 block, specifically inside the Current Measurement block.
This results in an error: Goto/From connections cannot cross nonvirtual subsystem boundaries.
Steps I’ve Taken:
I tried to manage the Current Measurement using standard Simulink blocks and physical signal converters but encountered issues with solver requirements.In other words, I cant add more complexity to an already fairly complex model, it would take forever.
I also attempted to create custom measurement logic but faced difficulties with integrating it seamlessly into the existing physical simulation. Again, here whatever I do requires a Solver and it turns it unfeasible to run (takes forever).
Error message I got:
Multiple Gotos found with tag named ‘DOC’
Component:Simulink | Category:Model error
First offending Goto ‘integrated_bat_fuel_2/powergui/EquivalentModel2/Yout/Goto2’
Component:Simulink | Category:Model error
Second offending Goto ‘integrated_bat_fuel_2/FuelCell Subsystem/FuelCell 1 kW 24V DC/Fuel Cell Stack/Current Measurement1/source’
Component:Simulink | Category:Model error
Additional Context:
I’m using Simulink with a combination of Simscape Electrical components.
The model involves a mix of physical and Simulink signals, making it critical to maintain compatibility across different simulation domains.
Any guidance or recommendations would be greatly appreciated!
Thank you, [Your Name]
Feel free to modify the draft as needed to better fit your situation or to add any other relevant details.
4o
Any ideas? Please advice , I already ran out of ideas and I have no clue on how to solve this, any guidance or recommendations would be greatly appreciated!
Thank you,
Raul simscape, simulink MATLAB Answers — New Questions
Disorganization of other components when adding the HTML component in MATLAB APP DESIGNER
Hello everyone,
I have a small application built in MATLAB APP DESIGNER. It is divided into a 2-PANEL APP (Left and Right). In the Right PANEL, there is a TABGROUP component that contains three TABS: IMAGE; HISTOGRAM; and HELP / SUPPORT, as shown in the figure below:
Inside each TAB, there is a PANEL component, and within each PANEL, I have AXES components for the IMAGE and HISTOGRAM TABS. Everything works fine until I add an HTML component inside the PANEL of the HELP / SUPPORT TAB, which will display a page with information about the application. When I do this, the other components become disorganized, as shown in the figure below.
Below, the figures demonstrate the disorganization of the components in the IMAGE and HISTOGRAM TABS.
Attached is the application code:
classdef segmentacao_palmeiras_tab_exported < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
GridLayout matlab.ui.container.GridLayout
LeftPanel matlab.ui.container.Panel
panelInfo matlab.ui.container.Panel
btnTipoSegmentacao matlab.ui.container.ButtonGroup
optSimples matlab.ui.control.RadioButton
optEspecies matlab.ui.control.RadioButton
txt_InfoGeo matlab.ui.control.Label
lbl_InfoGeo matlab.ui.control.Label
txt_InfoDim matlab.ui.control.Label
lbl_InfoDim matlab.ui.control.Label
txt_InfoLocal matlab.ui.control.Label
lbl_InfoLocal matlab.ui.control.Label
lbl_InfoImagem matlab.ui.control.Label
logoINPA matlab.ui.control.Image
logoUDESC matlab.ui.control.Image
RightPanel matlab.ui.container.Panel
panelBotoes matlab.ui.container.Panel
btnExportar matlab.ui.control.Button
btnHistograma matlab.ui.control.Button
btnProcessar matlab.ui.control.Button
btnCarregarImg matlab.ui.control.Button
TabGroup matlab.ui.container.TabGroup
IMAGEMTab matlab.ui.container.Tab
panelImagem matlab.ui.container.Panel
plotImagem matlab.ui.control.UIAxes
HISTOGRAMATab matlab.ui.container.Tab
panelHistogram matlab.ui.container.Panel
plotHistograma matlab.ui.control.UIAxes
AJUDASUPORTETab matlab.ui.container.Tab
HTML matlab.ui.control.HTML
end
% Properties that correspond to apps with auto-reflow
properties (Access = private)
onePanelWidth = 576;
end
properties (Access = private)
ImageFile % Arquivo de imagem;
ImageFile_pad % Arquivo de imagem ajustado
C_Categorical % Resultado gerado em CATEGORICAL
C_Categorical_Simples % Resultado gerado em CATEGORICAL
C_Uint8 % Resultado gerado em UINT8
C_Uint8_Simples % Resultado gerado em UINT8
B % Overlay da Imagem com o Resultado Espécies
B_Simples % Overlay da Imagem com o Resultado Simples
H % Grafico do Histograma
NetWork % Rede Neural
ImageFile_x % Largura
ImageFile_y % Altura
ImageFile_dim % Nr. Bandas
ImageFile_format % Formato do arquivo
R % Referencia Espacial da Imagem
S % Dados Geográficos geotiffinfo
X % Dados Geográficos struct.geotiffinfo
end
methods (Access = private)
% Tela de Progresso
function d = myprogress(app)
d = uiprogressdlg(app.UIFigure,’Title’,’Por favor aguarde…’,…
‘Message’,’Abrindo a aplicação’);
pause(.5);
d.Value = .33;
d.Message = ‘Carregando os dados necessários’;
pause(1);
d.Value = .67;
d.Message = ‘Processando os dados’;
pause(1);
d.Value = 1;
d.Message = ‘Finalizando’;
pause(1);
% Fecha dialog box
close(d);
end
function resetApp(app)
% Limpar as variáveis
clear;
% Limpar todas as propriedades
app.ImageFile = [];
app.ImageFile_pad = [];
app.C_Categorical = [];
app.C_Categorical_Simples = [];
app.C_Uint8 = [];
app.C_Uint8_Simples = [];
app.B = [];
app.B_Simples = [];
app.H = [];
app.NetWork = [];
app.ImageFile_x = [];
app.ImageFile_y = [];
app.ImageFile_dim = [];
app.ImageFile_format = [];
app.R = [];
app.S = [];
app.X = [];
% Limpar componentes de UI
%cla(app.plotImagem);
%cla(app.plotHistograma);
end
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
app.UIFigure.Position = [100 100 1100 630]; % [x y width height]
app.UIFigure.Resize = ‘off’;
% Especifica o diretório da exportacao
diretorio = ‘export’;
% Verifica se o diretório existe
if ~isfolder(diretorio)
% Se o diretório não existe, cria o diretório
mkdir(diretorio);
end
% Desabilita/Habilita os botões
app.btnCarregarImg.Enable = true;
app.btnProcessar.Enable = false;
app.btnHistograma.Enable = false;
app.btnExportar.Enable = false;
% Desabilita os tipos de segmentação
app.btnTipoSegmentacao.Enable = true;
app.optEspecies.Enable = false;
app.optSimples.Enable = false;
% Carregando a rede treinada
try
load(‘./net_cocao.mat’,’net_cocao’);
app.NetWork = net_cocao;
catch ME
report = getReport(ME);
uialert(app.UIFigure,report,’Erro’,’Interpreter’,’html’);
end
end
% Button pushed function: btnCarregarImg
function btnCarregarImgButtonPushed(app, event)
% Limpa a variaveis, propriedades e visualizadores.
app.resetApp();
% Desabilita/Habilita os botões
app.btnProcessar.Enable = false;
app.btnHistograma.Enable = false;
app.btnExportar.Enable = false;
% Desabilita os tipos de segmentação
app.btnTipoSegmentacao.Enable = true;
app.optSimples.Value = 0;
app.optEspecies.Enable = false;
app.optSimples.Enable = false;
% Chama a janela para carregar a imagem
% Armazena os dados da imagem do usuario
[filename,filepath] = uigetfile({‘*.tif’}, ‘Selecionar imagem’);
fullname = [filepath, filename];
% Abre a imagem de entrada selecionada pelo usuário
app.ImageFile = imread(fullname);
app.myprogress;
% Armazena informações sobre dimensões da imagem de entrada
[app.ImageFile_x,app.ImageFile_y,app.ImageFile_dim] = size(app.ImageFile);
% Armazena as informações geográficas da Imagem carregada
[~, r] = readgeoraster(fullname);
app.R = r;
app.X = geotiffinfo(fullname);
app.S = struct([app.X.GeoTIFFTags.GeoKeyDirectoryTag]);
app.ImageFile_format = app.X.Format;
% Verifica se o formato da imagem é TIF
if (string(app.ImageFile_format) ~= ‘tif’)
msg = {‘ATENÇÃO!’,’O formato da imagem deve ser TIF.’};
uialert(app.UIFigure,msg,’Warning’,’Icon’,’warning’);
end
% Verifica se o numero de bandas estão
% corretos para utilizar no programa.
if (app.ImageFile_dim ~= 3)
% Para o caso da imagem I tenha mais de 3 bandas deve-se retirar deixando
% somente 3 bandas
% Isolar as bandas da imagem
B1 = app.ImageFile(:,:,1);
B2 = app.ImageFile(:,:,2);
B3 = app.ImageFile(:,:,3);
% Junta as bandas isoladas
app.ImageFile = cat(3, B1, B2, B3);
msg = {‘ATENÇÃO!’,’A imagem de entrada deve ter 3 bandas. A imagem carregada engloba mais de 3 bandas. Foram consideradas somente as 3 primeiras bandas para o processamento.’};
uialert(app.UIFigure,msg,’Aviso’,’Icon’,’warning’);
end
% Ajustar a escala da imgem para a segmentação conforme o
% treinamento feito na CNN 512×512 pixels.
PatchSize = [512, 512];
app.ImageFile = imresize(app.ImageFile,’Scale’, PatchSize ./ 512);
% Apresenta a imagem no applicativo (Plot)
imshow(app.ImageFile,’Parent’,app.plotImagem);
%imagesc(app.plotImagem, app.ImageFile);
% Mostra as informaçções de tamanho e dimensão da imagem
%informacoes = sprintf(‘Arquivo: %ssprintf(‘Arquivo: %sn Tamanho (Bytes): %sn Altura: %sn Largula: %sn Nr. Bandas: %sn DATUM/Projeção: %sn’,app.X.Filename, app.X.FileSize, app.X.Height, app.X.Width, app.ImageFile_dim, app.X.PCS);n Altura: %sn Largula: %sn Nr. Bandas: %sn DATUM/Projeção: %sn’,app.X.Filename, app.X.FileSize, app.X.Height, app.X.Width, app.ImageFile_dim, app.X.PCS);
%app.txt_InfoLocal.Text = string(informacoes);
app.txt_InfoLocal.Text = string(app.X.Filename);
altura = string("Altura: " + app.X.Height);
largura = string("Largura: " + app.X.Width);
nr_dim = string("Nr. Bandas: " + app.ImageFile_dim);
tamanho = string("Tamanho (Bytes): " + app.X.FileSize);
dimensoes = [altura, largura, nr_dim, tamanho];
app.txt_InfoDim.Text = dimensoes;
app.txt_InfoGeo.Text = string(app.X.PCS);
% Desabilita/Habilita os botões
app.btnProcessar.Enable = true;
app.TabGroup.SelectedTab = app.IMAGEMTab;
end
% Button pushed function: btnProcessar
function btnProcessarButtonPushed(app, event)
% Desabilita o botão de Exportar/Carregar até o termino do processamento
app.btnCarregarImg.Enable = false;
app.btnExportar.Enable = false;
app.btnHistograma.Enable = false;
% Verifica se a GPU está disponível
useGPU = canUseGPU();
if useGPU
% Limpa a Memoria da GPU antes do processamento
D = gpuDevice();
reset(D);
end
% Cria a função para processar imagens de tamanho grandes por
% blocos
if useGPU
fun_proc_semanticseg = @(bloco)semanticseg(bloco.data, app.NetWork,ExecutionEnvironment="gpu",MiniBatchSize=16,OutputType="uint8",Acceleration="auto");
else
fun_proc_semanticseg = @(bloco)semanticseg(bloco.data, app.NetWork,ExecutionEnvironment="auto",MiniBatchSize=16,OutputType="uint8",Acceleration="auto");
end
% Redefine o tamanho do bloco para 512
tamanho_bloco = [512 512];
% Armazena o tamanho da imagem I
[height, width, ~] = size(app.ImageFile);
% Calcula o pad image para obter a dimensão que seja multiplo de tamanho do bloco
padSize(1) = tamanho_bloco(1) – mod(height, tamanho_bloco(1));
padSize(2) = tamanho_bloco(2) – mod(width, tamanho_bloco(2));
% Gera uma cópia da imagem com o tamanho adequado para o tamanho do Bloco.
% o tamanho acrestado (PAD) a imagem é preenchido com valor 0
app.ImageFile_pad = padarray(app.ImageFile, padSize, 0, ‘post’);
% Processa a segmentação
try
% Redefine o tamanho do bloco para 2048
tamanho_bloco = [2048 2048];
C = blockproc(app.ImageFile_pad, tamanho_bloco, fun_proc_semanticseg);
app.myprogress;
% The output is nosy, apply a median filter to remove spurious pixels.
C = medfilt2(C,[5 5]);
% Retorna o resultado para o tamanho original
C = C(1:height, 1:width);
C = changem(C,7,0);
catch ME
report = getReport(ME);
uialert(app.UIFigure,report,’Erro’,’Interpreter’,’html’);
end
% Definição dos Valores e Nome das Classes (ESPECIES)
labelIDs = [1 2 3 4 5 6 7];
classes = ["Açai" "Cocão" "Jaci" "Paxiuba" "Tucuma" "Floresta" "no-data"];
% Definição dos Valores e Nome das Classes (SIMPLES)
labelIDs_Simples = [1 2 3];
classes_Simples = ["Palmeiras" "Floresta" "no-data"];
% Alterar a segmentacao de ESPECIES -> SIMPLES
C_Simples = C;
C_Simples = changem(C_Simples,3,0);
C_Simples = changem(C_Simples,1,2);
C_Simples = changem(C_Simples,1,3);
C_Simples = changem(C_Simples,1,4);
C_Simples = changem(C_Simples,1,5);
C_Simples = changem(C_Simples,2,6);
C_Simples = changem(C_Simples,3,7);
% Converte a saida da segmentação de UINT8 para Categorical
% possibilitando a exportação.
app.C_Categorical = categorical(C, labelIDs, classes);
app.C_Uint8 = C;
app.C_Categorical_Simples = categorical(C_Simples,labelIDs_Simples,classes_Simples);
app.C_Uint8_Simples = C_Simples;
app.B = labeloverlay(app.ImageFile,C);
app.B_Simples = labeloverlay(app.ImageFile,C_Simples);
% Monta a sobreposição da Imagem com o resultado gerado da
% segmentação
if app.optSimples.Value ~= 1
% Apresenta o resultado da segmentação no applicativo (Plot)
%imagesc(app.plotImagem, B);
imshow(app.B_Simples,’Parent’,app.plotImagem);
%app.TabGroup.SelectedTab = app.IMAGEMTab;
else % Espécie
% Apresenta o resultado da segmentação no applicativo (Plot)
%imagesc(app.plotImagem, B);
imshow(app.B,’Parent’,app.plotImagem);
%app.TabGroup.SelectedTab = app.IMAGEMTab;
end
% Habilita o botão de Exportar/Carregar até o termino do processamento
app.btnCarregarImg.Enable = true;
app.btnHistograma.Enable = true;
app.btnExportar.Enable = true;
app.btnProcessar.Enable = false;
% Habilita os tipos de segmentação
app.btnTipoSegmentacao.Enable = true;
app.optEspecies.Enable = true;
app.optSimples.Enable = true;
end
% Button pushed function: btnExportar
function btnExportarButtonPushed(app, event)
% Habilita o botão de Exportar/Carregar até o termino do processamento
app.btnCarregarImg.Enable = false;
app.btnHistograma.Enable = false;
app.btnProcessar.Enable = false;
% Processa a exportação do resultado da segmentação
try
if app.optSimples.Value ~= 1
geotiffwrite(‘./export/classImg.tif’,app.C_Uint8_Simples,app.R,’GeoKeyDirectoryTag’,app.S);
app.myprogress;
else
geotiffwrite(‘./export/classImg.tif’,app.C_Uint8,app.R,’GeoKeyDirectoryTag’,app.S);
app.myprogress;
end
message = ["Resultado Exportado!","Procure o arquivo classImg.tif na pasta export."];
uialert(app.UIFigure,message,"Sucesso", "Icon","success");
catch ME
report = getReport(ME);
uialert(app.UIFigure,report,’Erro’,’Interpreter’,’html’);
end
% Habilita o botão de Exportar/Carregar até o termino do processamento
app.btnCarregarImg.Enable = true;
app.btnHistograma.Enable = true;
app.btnExportar.Enable = true;
app.btnProcessar.Enable = false;
end
% Button pushed function: btnHistograma
function btnHistogramaButtonPushed(app, event)
% Processa o histograma do resultado da segmentação
try
% histograma.
if app.optSimples.Value ~= 1
app.H = histogram(app.plotHistograma,app.C_Categorical_Simples …
,"FaceColor",[1 0 0],"EdgeColor","none");
else % Espécie
app.H = histogram(app.plotHistograma,app.C_Categorical …
,"FaceColor",[1 0 0],"EdgeColor","none");
end
catch ME
report = getReport(ME);
uialert(app.UIFigure,report,’Erro’,’Interpreter’,’html’);
end
app.TabGroup.SelectedTab = app.HISTOGRAMATab;
end
% Selection changed function: btnTipoSegmentacao
function btnTipoSegmentacaoSelectionChanged(app, event)
% Escolheu o Tipo Simples
if app.optSimples.Value ~= 1
imshow(app.B_Simples,’Parent’,app.plotImagem);
app.TabGroup.SelectedTab = app.IMAGEMTab;
% Verifica se existe o histograma
if isprop(app, ‘H’) && ~isempty(app.H)
app.H = histogram(app.plotHistograma, app.C_Categorical_Simples, …
‘FaceColor’, [1 0 0], ‘EdgeColor’, ‘none’);
end
else % Espécies
imshow(app.B,’Parent’,app.plotImagem);
app.TabGroup.SelectedTab = app.IMAGEMTab;
% Verifica se existe o histograma
if isprop(app, ‘H’) && ~isempty(app.H)
app.H = histogram(app.plotHistograma, app.C_Categorical, …
‘FaceColor’, [1 0 0], ‘EdgeColor’, ‘none’);
end
end
end
% Changes arrangement of the app based on UIFigure width
function updateAppLayout(app, event)
currentFigureWidth = app.UIFigure.Position(3);
if(currentFigureWidth <= app.onePanelWidth)
% Change to a 2×1 grid
app.GridLayout.RowHeight = {397, 397};
app.GridLayout.ColumnWidth = {‘1x’};
app.RightPanel.Layout.Row = 2;
app.RightPanel.Layout.Column = 1;
else
% Change to a 1×2 grid
app.GridLayout.RowHeight = {‘1x’};
app.GridLayout.ColumnWidth = {212, ‘1x’};
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
end
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Get the file path for locating images
pathToMLAPP = fileparts(mfilename(‘fullpath’));
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure(‘Visible’, ‘off’);
app.UIFigure.AutoResizeChildren = ‘off’;
app.UIFigure.Position = [100 100 698 397];
app.UIFigure.Name = ‘MATLAB App’;
app.UIFigure.Resize = ‘off’;
app.UIFigure.SizeChangedFcn = createCallbackFcn(app, @updateAppLayout, true);
% Create GridLayout
app.GridLayout = uigridlayout(app.UIFigure);
app.GridLayout.ColumnWidth = {212, ‘1x’};
app.GridLayout.RowHeight = {‘1x’};
app.GridLayout.ColumnSpacing = 0;
app.GridLayout.RowSpacing = 0;
app.GridLayout.Padding = [0 0 0 0];
app.GridLayout.Scrollable = ‘on’;
% Create LeftPanel
app.LeftPanel = uipanel(app.GridLayout);
app.LeftPanel.Layout.Row = 1;
app.LeftPanel.Layout.Column = 1;
% Create panelInfo
app.panelInfo = uipanel(app.LeftPanel);
app.panelInfo.BorderType = ‘none’;
app.panelInfo.Position = [7 7 200 384];
% Create logoUDESC
app.logoUDESC = uiimage(app.panelInfo);
app.logoUDESC.Position = [8 345 83 34];
app.logoUDESC.ImageSource = fullfile(pathToMLAPP, ‘udesc2_logo.png’);
% Create logoINPA
app.logoINPA = uiimage(app.panelInfo);
app.logoINPA.Position = [110 346 83 34];
app.logoINPA.ImageSource = fullfile(pathToMLAPP, ‘inpa-acre_logo.png’);
% Create lbl_InfoImagem
app.lbl_InfoImagem = uilabel(app.panelInfo);
app.lbl_InfoImagem.HorizontalAlignment = ‘center’;
app.lbl_InfoImagem.FontSize = 14;
app.lbl_InfoImagem.FontWeight = ‘bold’;
app.lbl_InfoImagem.Position = [7 315 186 22];
app.lbl_InfoImagem.Text = ‘Informações da Entrada’;
% Create lbl_InfoLocal
app.lbl_InfoLocal = uilabel(app.panelInfo);
app.lbl_InfoLocal.FontWeight = ‘bold’;
app.lbl_InfoLocal.Position = [7 287 186 22];
app.lbl_InfoLocal.Text = ‘Local:’;
% Create txt_InfoLocal
app.txt_InfoLocal = uilabel(app.panelInfo);
app.txt_InfoLocal.VerticalAlignment = ‘top’;
app.txt_InfoLocal.WordWrap = ‘on’;
app.txt_InfoLocal.FontSize = 9;
app.txt_InfoLocal.Position = [7 246 186 34];
app.txt_InfoLocal.Text = ‘ ‘;
% Create lbl_InfoDim
app.lbl_InfoDim = uilabel(app.panelInfo);
app.lbl_InfoDim.FontWeight = ‘bold’;
app.lbl_InfoDim.Position = [7 218 186 22];
app.lbl_InfoDim.Text = ‘Dimensão:’;
% Create txt_InfoDim
app.txt_InfoDim = uilabel(app.panelInfo);
app.txt_InfoDim.VerticalAlignment = ‘top’;
app.txt_InfoDim.WordWrap = ‘on’;
app.txt_InfoDim.FontSize = 9;
app.txt_InfoDim.Position = [7 131 186 80];
app.txt_InfoDim.Text = ‘ ‘;
% Create lbl_InfoGeo
app.lbl_InfoGeo = uilabel(app.panelInfo);
app.lbl_InfoGeo.FontWeight = ‘bold’;
app.lbl_InfoGeo.Position = [7 106 186 22];
app.lbl_InfoGeo.Text = ‘Dados Geográficos:’;
% Create txt_InfoGeo
app.txt_InfoGeo = uilabel(app.panelInfo);
app.txt_InfoGeo.VerticalAlignment = ‘top’;
app.txt_InfoGeo.WordWrap = ‘on’;
app.txt_InfoGeo.FontSize = 9;
app.txt_InfoGeo.Position = [7 65 186 34];
app.txt_InfoGeo.Text = ‘ ‘;
% Create btnTipoSegmentacao
app.btnTipoSegmentacao = uibuttongroup(app.panelInfo);
app.btnTipoSegmentacao.SelectionChangedFcn = createCallbackFcn(app, @btnTipoSegmentacaoSelectionChanged, true);
app.btnTipoSegmentacao.Title = ‘Tipo de Segmentação:’;
app.btnTipoSegmentacao.Position = [6 10 186 49];
% Create optEspecies
app.optEspecies = uiradiobutton(app.btnTipoSegmentacao);
app.optEspecies.Enable = ‘off’;
app.optEspecies.Text = ‘Simples’;
app.optEspecies.Position = [11 3 64 22];
app.optEspecies.Value = true;
% Create optSimples
app.optSimples = uiradiobutton(app.btnTipoSegmentacao);
app.optSimples.Enable = ‘off’;
app.optSimples.Text = ‘Espécies’;
app.optSimples.Position = [103 3 70 22];
% Create RightPanel
app.RightPanel = uipanel(app.GridLayout);
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
% Create TabGroup
app.TabGroup = uitabgroup(app.RightPanel);
app.TabGroup.AutoResizeChildren = ‘off’;
app.TabGroup.Position = [11 65 467 325];
% Create IMAGEMTab
app.IMAGEMTab = uitab(app.TabGroup);
app.IMAGEMTab.AutoResizeChildren = ‘off’;
app.IMAGEMTab.Title = ‘IMAGEM’;
% Create panelImagem
app.panelImagem = uipanel(app.IMAGEMTab);
app.panelImagem.AutoResizeChildren = ‘off’;
app.panelImagem.BorderType = ‘none’;
app.panelImagem.Position = [8 8 452 284];
% Create plotImagem
app.plotImagem = uiaxes(app.panelImagem);
app.plotImagem.XTick = [];
app.plotImagem.YTick = [];
app.plotImagem.ZTick = [];
app.plotImagem.Color = [0.9412 0.9412 0.9412];
app.plotImagem.Box = ‘on’;
app.plotImagem.Position = [6 8 437 271];
% Create HISTOGRAMATab
app.HISTOGRAMATab = uitab(app.TabGroup);
app.HISTOGRAMATab.AutoResizeChildren = ‘off’;
app.HISTOGRAMATab.Title = ‘HISTOGRAMA’;
% Create panelHistogram
app.panelHistogram = uipanel(app.HISTOGRAMATab);
app.panelHistogram.AutoResizeChildren = ‘off’;
app.panelHistogram.BorderType = ‘none’;
app.panelHistogram.Position = [8 8 452 284];
% Create plotHistograma
app.plotHistograma = uiaxes(app.panelHistogram);
title(app.plotHistograma, ‘Frequência por Espécies’)
xlabel(app.plotHistograma, ‘Espécies de Palmeiras’)
ylabel(app.plotHistograma, ‘Nr. Pixels’)
app.plotHistograma.Toolbar.Visible = ‘off’;
app.plotHistograma.Box = ‘on’;
app.plotHistograma.XGrid = ‘on’;
app.plotHistograma.YGrid = ‘on’;
app.plotHistograma.Position = [6 8 437 271];
% Create AJUDASUPORTETab
app.AJUDASUPORTETab = uitab(app.TabGroup);
app.AJUDASUPORTETab.AutoResizeChildren = ‘off’;
app.AJUDASUPORTETab.Title = ‘AJUDA / SUPORTE’;
% Create HTML
app.HTML = uihtml(app.AJUDASUPORTETab);
app.HTML.HTMLSource = ‘suporte.html’;
app.HTML.Position = [15 14 435 272];
% Create panelBotoes
app.panelBotoes = uipanel(app.RightPanel);
app.panelBotoes.BorderType = ‘none’;
app.panelBotoes.Position = [12 7 465 48];
% Create btnCarregarImg
app.btnCarregarImg = uibutton(app.panelBotoes, ‘push’);
app.btnCarregarImg.ButtonPushedFcn = createCallbackFcn(app, @btnCarregarImgButtonPushed, true);
app.btnCarregarImg.WordWrap = ‘on’;
app.btnCarregarImg.Position = [21 8 91 35];
app.btnCarregarImg.Text = ‘Carregar Imagem…’;
% Create btnProcessar
app.btnProcessar = uibutton(app.panelBotoes, ‘push’);
app.btnProcessar.ButtonPushedFcn = createCallbackFcn(app, @btnProcessarButtonPushed, true);
app.btnProcessar.WordWrap = ‘on’;
app.btnProcessar.Enable = ‘off’;
app.btnProcessar.Position = [132 8 91 35];
app.btnProcessar.Text = ‘Processar Segmentação’;
% Create btnHistograma
app.btnHistograma = uibutton(app.panelBotoes, ‘push’);
app.btnHistograma.ButtonPushedFcn = createCallbackFcn(app, @btnHistogramaButtonPushed, true);
app.btnHistograma.WordWrap = ‘on’;
app.btnHistograma.Enable = ‘off’;
app.btnHistograma.Position = [243 8 91 35];
app.btnHistograma.Text = ‘Histograma’;
% Create btnExportar
app.btnExportar = uibutton(app.panelBotoes, ‘push’);
app.btnExportar.ButtonPushedFcn = createCallbackFcn(app, @btnExportarButtonPushed, true);
app.btnExportar.WordWrap = ‘on’;
app.btnExportar.Enable = ‘off’;
app.btnExportar.Position = [354 8 91 35];
app.btnExportar.Text = ‘Exportar Segmentação’;
% Show the figure after all components are created
app.UIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = segmentacao_palmeiras_tab_exported
runningApp = getRunningApp(app);
% Check for running singleton app
if isempty(runningApp)
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
else
% Focus the running singleton app
figure(runningApp.UIFigure)
app = runningApp;
end
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end
Could someone please help me resolve this issue?
Best regards,
Airton Gaio Jr.Hello everyone,
I have a small application built in MATLAB APP DESIGNER. It is divided into a 2-PANEL APP (Left and Right). In the Right PANEL, there is a TABGROUP component that contains three TABS: IMAGE; HISTOGRAM; and HELP / SUPPORT, as shown in the figure below:
Inside each TAB, there is a PANEL component, and within each PANEL, I have AXES components for the IMAGE and HISTOGRAM TABS. Everything works fine until I add an HTML component inside the PANEL of the HELP / SUPPORT TAB, which will display a page with information about the application. When I do this, the other components become disorganized, as shown in the figure below.
Below, the figures demonstrate the disorganization of the components in the IMAGE and HISTOGRAM TABS.
Attached is the application code:
classdef segmentacao_palmeiras_tab_exported < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
GridLayout matlab.ui.container.GridLayout
LeftPanel matlab.ui.container.Panel
panelInfo matlab.ui.container.Panel
btnTipoSegmentacao matlab.ui.container.ButtonGroup
optSimples matlab.ui.control.RadioButton
optEspecies matlab.ui.control.RadioButton
txt_InfoGeo matlab.ui.control.Label
lbl_InfoGeo matlab.ui.control.Label
txt_InfoDim matlab.ui.control.Label
lbl_InfoDim matlab.ui.control.Label
txt_InfoLocal matlab.ui.control.Label
lbl_InfoLocal matlab.ui.control.Label
lbl_InfoImagem matlab.ui.control.Label
logoINPA matlab.ui.control.Image
logoUDESC matlab.ui.control.Image
RightPanel matlab.ui.container.Panel
panelBotoes matlab.ui.container.Panel
btnExportar matlab.ui.control.Button
btnHistograma matlab.ui.control.Button
btnProcessar matlab.ui.control.Button
btnCarregarImg matlab.ui.control.Button
TabGroup matlab.ui.container.TabGroup
IMAGEMTab matlab.ui.container.Tab
panelImagem matlab.ui.container.Panel
plotImagem matlab.ui.control.UIAxes
HISTOGRAMATab matlab.ui.container.Tab
panelHistogram matlab.ui.container.Panel
plotHistograma matlab.ui.control.UIAxes
AJUDASUPORTETab matlab.ui.container.Tab
HTML matlab.ui.control.HTML
end
% Properties that correspond to apps with auto-reflow
properties (Access = private)
onePanelWidth = 576;
end
properties (Access = private)
ImageFile % Arquivo de imagem;
ImageFile_pad % Arquivo de imagem ajustado
C_Categorical % Resultado gerado em CATEGORICAL
C_Categorical_Simples % Resultado gerado em CATEGORICAL
C_Uint8 % Resultado gerado em UINT8
C_Uint8_Simples % Resultado gerado em UINT8
B % Overlay da Imagem com o Resultado Espécies
B_Simples % Overlay da Imagem com o Resultado Simples
H % Grafico do Histograma
NetWork % Rede Neural
ImageFile_x % Largura
ImageFile_y % Altura
ImageFile_dim % Nr. Bandas
ImageFile_format % Formato do arquivo
R % Referencia Espacial da Imagem
S % Dados Geográficos geotiffinfo
X % Dados Geográficos struct.geotiffinfo
end
methods (Access = private)
% Tela de Progresso
function d = myprogress(app)
d = uiprogressdlg(app.UIFigure,’Title’,’Por favor aguarde…’,…
‘Message’,’Abrindo a aplicação’);
pause(.5);
d.Value = .33;
d.Message = ‘Carregando os dados necessários’;
pause(1);
d.Value = .67;
d.Message = ‘Processando os dados’;
pause(1);
d.Value = 1;
d.Message = ‘Finalizando’;
pause(1);
% Fecha dialog box
close(d);
end
function resetApp(app)
% Limpar as variáveis
clear;
% Limpar todas as propriedades
app.ImageFile = [];
app.ImageFile_pad = [];
app.C_Categorical = [];
app.C_Categorical_Simples = [];
app.C_Uint8 = [];
app.C_Uint8_Simples = [];
app.B = [];
app.B_Simples = [];
app.H = [];
app.NetWork = [];
app.ImageFile_x = [];
app.ImageFile_y = [];
app.ImageFile_dim = [];
app.ImageFile_format = [];
app.R = [];
app.S = [];
app.X = [];
% Limpar componentes de UI
%cla(app.plotImagem);
%cla(app.plotHistograma);
end
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
app.UIFigure.Position = [100 100 1100 630]; % [x y width height]
app.UIFigure.Resize = ‘off’;
% Especifica o diretório da exportacao
diretorio = ‘export’;
% Verifica se o diretório existe
if ~isfolder(diretorio)
% Se o diretório não existe, cria o diretório
mkdir(diretorio);
end
% Desabilita/Habilita os botões
app.btnCarregarImg.Enable = true;
app.btnProcessar.Enable = false;
app.btnHistograma.Enable = false;
app.btnExportar.Enable = false;
% Desabilita os tipos de segmentação
app.btnTipoSegmentacao.Enable = true;
app.optEspecies.Enable = false;
app.optSimples.Enable = false;
% Carregando a rede treinada
try
load(‘./net_cocao.mat’,’net_cocao’);
app.NetWork = net_cocao;
catch ME
report = getReport(ME);
uialert(app.UIFigure,report,’Erro’,’Interpreter’,’html’);
end
end
% Button pushed function: btnCarregarImg
function btnCarregarImgButtonPushed(app, event)
% Limpa a variaveis, propriedades e visualizadores.
app.resetApp();
% Desabilita/Habilita os botões
app.btnProcessar.Enable = false;
app.btnHistograma.Enable = false;
app.btnExportar.Enable = false;
% Desabilita os tipos de segmentação
app.btnTipoSegmentacao.Enable = true;
app.optSimples.Value = 0;
app.optEspecies.Enable = false;
app.optSimples.Enable = false;
% Chama a janela para carregar a imagem
% Armazena os dados da imagem do usuario
[filename,filepath] = uigetfile({‘*.tif’}, ‘Selecionar imagem’);
fullname = [filepath, filename];
% Abre a imagem de entrada selecionada pelo usuário
app.ImageFile = imread(fullname);
app.myprogress;
% Armazena informações sobre dimensões da imagem de entrada
[app.ImageFile_x,app.ImageFile_y,app.ImageFile_dim] = size(app.ImageFile);
% Armazena as informações geográficas da Imagem carregada
[~, r] = readgeoraster(fullname);
app.R = r;
app.X = geotiffinfo(fullname);
app.S = struct([app.X.GeoTIFFTags.GeoKeyDirectoryTag]);
app.ImageFile_format = app.X.Format;
% Verifica se o formato da imagem é TIF
if (string(app.ImageFile_format) ~= ‘tif’)
msg = {‘ATENÇÃO!’,’O formato da imagem deve ser TIF.’};
uialert(app.UIFigure,msg,’Warning’,’Icon’,’warning’);
end
% Verifica se o numero de bandas estão
% corretos para utilizar no programa.
if (app.ImageFile_dim ~= 3)
% Para o caso da imagem I tenha mais de 3 bandas deve-se retirar deixando
% somente 3 bandas
% Isolar as bandas da imagem
B1 = app.ImageFile(:,:,1);
B2 = app.ImageFile(:,:,2);
B3 = app.ImageFile(:,:,3);
% Junta as bandas isoladas
app.ImageFile = cat(3, B1, B2, B3);
msg = {‘ATENÇÃO!’,’A imagem de entrada deve ter 3 bandas. A imagem carregada engloba mais de 3 bandas. Foram consideradas somente as 3 primeiras bandas para o processamento.’};
uialert(app.UIFigure,msg,’Aviso’,’Icon’,’warning’);
end
% Ajustar a escala da imgem para a segmentação conforme o
% treinamento feito na CNN 512×512 pixels.
PatchSize = [512, 512];
app.ImageFile = imresize(app.ImageFile,’Scale’, PatchSize ./ 512);
% Apresenta a imagem no applicativo (Plot)
imshow(app.ImageFile,’Parent’,app.plotImagem);
%imagesc(app.plotImagem, app.ImageFile);
% Mostra as informaçções de tamanho e dimensão da imagem
%informacoes = sprintf(‘Arquivo: %ssprintf(‘Arquivo: %sn Tamanho (Bytes): %sn Altura: %sn Largula: %sn Nr. Bandas: %sn DATUM/Projeção: %sn’,app.X.Filename, app.X.FileSize, app.X.Height, app.X.Width, app.ImageFile_dim, app.X.PCS);n Altura: %sn Largula: %sn Nr. Bandas: %sn DATUM/Projeção: %sn’,app.X.Filename, app.X.FileSize, app.X.Height, app.X.Width, app.ImageFile_dim, app.X.PCS);
%app.txt_InfoLocal.Text = string(informacoes);
app.txt_InfoLocal.Text = string(app.X.Filename);
altura = string("Altura: " + app.X.Height);
largura = string("Largura: " + app.X.Width);
nr_dim = string("Nr. Bandas: " + app.ImageFile_dim);
tamanho = string("Tamanho (Bytes): " + app.X.FileSize);
dimensoes = [altura, largura, nr_dim, tamanho];
app.txt_InfoDim.Text = dimensoes;
app.txt_InfoGeo.Text = string(app.X.PCS);
% Desabilita/Habilita os botões
app.btnProcessar.Enable = true;
app.TabGroup.SelectedTab = app.IMAGEMTab;
end
% Button pushed function: btnProcessar
function btnProcessarButtonPushed(app, event)
% Desabilita o botão de Exportar/Carregar até o termino do processamento
app.btnCarregarImg.Enable = false;
app.btnExportar.Enable = false;
app.btnHistograma.Enable = false;
% Verifica se a GPU está disponível
useGPU = canUseGPU();
if useGPU
% Limpa a Memoria da GPU antes do processamento
D = gpuDevice();
reset(D);
end
% Cria a função para processar imagens de tamanho grandes por
% blocos
if useGPU
fun_proc_semanticseg = @(bloco)semanticseg(bloco.data, app.NetWork,ExecutionEnvironment="gpu",MiniBatchSize=16,OutputType="uint8",Acceleration="auto");
else
fun_proc_semanticseg = @(bloco)semanticseg(bloco.data, app.NetWork,ExecutionEnvironment="auto",MiniBatchSize=16,OutputType="uint8",Acceleration="auto");
end
% Redefine o tamanho do bloco para 512
tamanho_bloco = [512 512];
% Armazena o tamanho da imagem I
[height, width, ~] = size(app.ImageFile);
% Calcula o pad image para obter a dimensão que seja multiplo de tamanho do bloco
padSize(1) = tamanho_bloco(1) – mod(height, tamanho_bloco(1));
padSize(2) = tamanho_bloco(2) – mod(width, tamanho_bloco(2));
% Gera uma cópia da imagem com o tamanho adequado para o tamanho do Bloco.
% o tamanho acrestado (PAD) a imagem é preenchido com valor 0
app.ImageFile_pad = padarray(app.ImageFile, padSize, 0, ‘post’);
% Processa a segmentação
try
% Redefine o tamanho do bloco para 2048
tamanho_bloco = [2048 2048];
C = blockproc(app.ImageFile_pad, tamanho_bloco, fun_proc_semanticseg);
app.myprogress;
% The output is nosy, apply a median filter to remove spurious pixels.
C = medfilt2(C,[5 5]);
% Retorna o resultado para o tamanho original
C = C(1:height, 1:width);
C = changem(C,7,0);
catch ME
report = getReport(ME);
uialert(app.UIFigure,report,’Erro’,’Interpreter’,’html’);
end
% Definição dos Valores e Nome das Classes (ESPECIES)
labelIDs = [1 2 3 4 5 6 7];
classes = ["Açai" "Cocão" "Jaci" "Paxiuba" "Tucuma" "Floresta" "no-data"];
% Definição dos Valores e Nome das Classes (SIMPLES)
labelIDs_Simples = [1 2 3];
classes_Simples = ["Palmeiras" "Floresta" "no-data"];
% Alterar a segmentacao de ESPECIES -> SIMPLES
C_Simples = C;
C_Simples = changem(C_Simples,3,0);
C_Simples = changem(C_Simples,1,2);
C_Simples = changem(C_Simples,1,3);
C_Simples = changem(C_Simples,1,4);
C_Simples = changem(C_Simples,1,5);
C_Simples = changem(C_Simples,2,6);
C_Simples = changem(C_Simples,3,7);
% Converte a saida da segmentação de UINT8 para Categorical
% possibilitando a exportação.
app.C_Categorical = categorical(C, labelIDs, classes);
app.C_Uint8 = C;
app.C_Categorical_Simples = categorical(C_Simples,labelIDs_Simples,classes_Simples);
app.C_Uint8_Simples = C_Simples;
app.B = labeloverlay(app.ImageFile,C);
app.B_Simples = labeloverlay(app.ImageFile,C_Simples);
% Monta a sobreposição da Imagem com o resultado gerado da
% segmentação
if app.optSimples.Value ~= 1
% Apresenta o resultado da segmentação no applicativo (Plot)
%imagesc(app.plotImagem, B);
imshow(app.B_Simples,’Parent’,app.plotImagem);
%app.TabGroup.SelectedTab = app.IMAGEMTab;
else % Espécie
% Apresenta o resultado da segmentação no applicativo (Plot)
%imagesc(app.plotImagem, B);
imshow(app.B,’Parent’,app.plotImagem);
%app.TabGroup.SelectedTab = app.IMAGEMTab;
end
% Habilita o botão de Exportar/Carregar até o termino do processamento
app.btnCarregarImg.Enable = true;
app.btnHistograma.Enable = true;
app.btnExportar.Enable = true;
app.btnProcessar.Enable = false;
% Habilita os tipos de segmentação
app.btnTipoSegmentacao.Enable = true;
app.optEspecies.Enable = true;
app.optSimples.Enable = true;
end
% Button pushed function: btnExportar
function btnExportarButtonPushed(app, event)
% Habilita o botão de Exportar/Carregar até o termino do processamento
app.btnCarregarImg.Enable = false;
app.btnHistograma.Enable = false;
app.btnProcessar.Enable = false;
% Processa a exportação do resultado da segmentação
try
if app.optSimples.Value ~= 1
geotiffwrite(‘./export/classImg.tif’,app.C_Uint8_Simples,app.R,’GeoKeyDirectoryTag’,app.S);
app.myprogress;
else
geotiffwrite(‘./export/classImg.tif’,app.C_Uint8,app.R,’GeoKeyDirectoryTag’,app.S);
app.myprogress;
end
message = ["Resultado Exportado!","Procure o arquivo classImg.tif na pasta export."];
uialert(app.UIFigure,message,"Sucesso", "Icon","success");
catch ME
report = getReport(ME);
uialert(app.UIFigure,report,’Erro’,’Interpreter’,’html’);
end
% Habilita o botão de Exportar/Carregar até o termino do processamento
app.btnCarregarImg.Enable = true;
app.btnHistograma.Enable = true;
app.btnExportar.Enable = true;
app.btnProcessar.Enable = false;
end
% Button pushed function: btnHistograma
function btnHistogramaButtonPushed(app, event)
% Processa o histograma do resultado da segmentação
try
% histograma.
if app.optSimples.Value ~= 1
app.H = histogram(app.plotHistograma,app.C_Categorical_Simples …
,"FaceColor",[1 0 0],"EdgeColor","none");
else % Espécie
app.H = histogram(app.plotHistograma,app.C_Categorical …
,"FaceColor",[1 0 0],"EdgeColor","none");
end
catch ME
report = getReport(ME);
uialert(app.UIFigure,report,’Erro’,’Interpreter’,’html’);
end
app.TabGroup.SelectedTab = app.HISTOGRAMATab;
end
% Selection changed function: btnTipoSegmentacao
function btnTipoSegmentacaoSelectionChanged(app, event)
% Escolheu o Tipo Simples
if app.optSimples.Value ~= 1
imshow(app.B_Simples,’Parent’,app.plotImagem);
app.TabGroup.SelectedTab = app.IMAGEMTab;
% Verifica se existe o histograma
if isprop(app, ‘H’) && ~isempty(app.H)
app.H = histogram(app.plotHistograma, app.C_Categorical_Simples, …
‘FaceColor’, [1 0 0], ‘EdgeColor’, ‘none’);
end
else % Espécies
imshow(app.B,’Parent’,app.plotImagem);
app.TabGroup.SelectedTab = app.IMAGEMTab;
% Verifica se existe o histograma
if isprop(app, ‘H’) && ~isempty(app.H)
app.H = histogram(app.plotHistograma, app.C_Categorical, …
‘FaceColor’, [1 0 0], ‘EdgeColor’, ‘none’);
end
end
end
% Changes arrangement of the app based on UIFigure width
function updateAppLayout(app, event)
currentFigureWidth = app.UIFigure.Position(3);
if(currentFigureWidth <= app.onePanelWidth)
% Change to a 2×1 grid
app.GridLayout.RowHeight = {397, 397};
app.GridLayout.ColumnWidth = {‘1x’};
app.RightPanel.Layout.Row = 2;
app.RightPanel.Layout.Column = 1;
else
% Change to a 1×2 grid
app.GridLayout.RowHeight = {‘1x’};
app.GridLayout.ColumnWidth = {212, ‘1x’};
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
end
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Get the file path for locating images
pathToMLAPP = fileparts(mfilename(‘fullpath’));
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure(‘Visible’, ‘off’);
app.UIFigure.AutoResizeChildren = ‘off’;
app.UIFigure.Position = [100 100 698 397];
app.UIFigure.Name = ‘MATLAB App’;
app.UIFigure.Resize = ‘off’;
app.UIFigure.SizeChangedFcn = createCallbackFcn(app, @updateAppLayout, true);
% Create GridLayout
app.GridLayout = uigridlayout(app.UIFigure);
app.GridLayout.ColumnWidth = {212, ‘1x’};
app.GridLayout.RowHeight = {‘1x’};
app.GridLayout.ColumnSpacing = 0;
app.GridLayout.RowSpacing = 0;
app.GridLayout.Padding = [0 0 0 0];
app.GridLayout.Scrollable = ‘on’;
% Create LeftPanel
app.LeftPanel = uipanel(app.GridLayout);
app.LeftPanel.Layout.Row = 1;
app.LeftPanel.Layout.Column = 1;
% Create panelInfo
app.panelInfo = uipanel(app.LeftPanel);
app.panelInfo.BorderType = ‘none’;
app.panelInfo.Position = [7 7 200 384];
% Create logoUDESC
app.logoUDESC = uiimage(app.panelInfo);
app.logoUDESC.Position = [8 345 83 34];
app.logoUDESC.ImageSource = fullfile(pathToMLAPP, ‘udesc2_logo.png’);
% Create logoINPA
app.logoINPA = uiimage(app.panelInfo);
app.logoINPA.Position = [110 346 83 34];
app.logoINPA.ImageSource = fullfile(pathToMLAPP, ‘inpa-acre_logo.png’);
% Create lbl_InfoImagem
app.lbl_InfoImagem = uilabel(app.panelInfo);
app.lbl_InfoImagem.HorizontalAlignment = ‘center’;
app.lbl_InfoImagem.FontSize = 14;
app.lbl_InfoImagem.FontWeight = ‘bold’;
app.lbl_InfoImagem.Position = [7 315 186 22];
app.lbl_InfoImagem.Text = ‘Informações da Entrada’;
% Create lbl_InfoLocal
app.lbl_InfoLocal = uilabel(app.panelInfo);
app.lbl_InfoLocal.FontWeight = ‘bold’;
app.lbl_InfoLocal.Position = [7 287 186 22];
app.lbl_InfoLocal.Text = ‘Local:’;
% Create txt_InfoLocal
app.txt_InfoLocal = uilabel(app.panelInfo);
app.txt_InfoLocal.VerticalAlignment = ‘top’;
app.txt_InfoLocal.WordWrap = ‘on’;
app.txt_InfoLocal.FontSize = 9;
app.txt_InfoLocal.Position = [7 246 186 34];
app.txt_InfoLocal.Text = ‘ ‘;
% Create lbl_InfoDim
app.lbl_InfoDim = uilabel(app.panelInfo);
app.lbl_InfoDim.FontWeight = ‘bold’;
app.lbl_InfoDim.Position = [7 218 186 22];
app.lbl_InfoDim.Text = ‘Dimensão:’;
% Create txt_InfoDim
app.txt_InfoDim = uilabel(app.panelInfo);
app.txt_InfoDim.VerticalAlignment = ‘top’;
app.txt_InfoDim.WordWrap = ‘on’;
app.txt_InfoDim.FontSize = 9;
app.txt_InfoDim.Position = [7 131 186 80];
app.txt_InfoDim.Text = ‘ ‘;
% Create lbl_InfoGeo
app.lbl_InfoGeo = uilabel(app.panelInfo);
app.lbl_InfoGeo.FontWeight = ‘bold’;
app.lbl_InfoGeo.Position = [7 106 186 22];
app.lbl_InfoGeo.Text = ‘Dados Geográficos:’;
% Create txt_InfoGeo
app.txt_InfoGeo = uilabel(app.panelInfo);
app.txt_InfoGeo.VerticalAlignment = ‘top’;
app.txt_InfoGeo.WordWrap = ‘on’;
app.txt_InfoGeo.FontSize = 9;
app.txt_InfoGeo.Position = [7 65 186 34];
app.txt_InfoGeo.Text = ‘ ‘;
% Create btnTipoSegmentacao
app.btnTipoSegmentacao = uibuttongroup(app.panelInfo);
app.btnTipoSegmentacao.SelectionChangedFcn = createCallbackFcn(app, @btnTipoSegmentacaoSelectionChanged, true);
app.btnTipoSegmentacao.Title = ‘Tipo de Segmentação:’;
app.btnTipoSegmentacao.Position = [6 10 186 49];
% Create optEspecies
app.optEspecies = uiradiobutton(app.btnTipoSegmentacao);
app.optEspecies.Enable = ‘off’;
app.optEspecies.Text = ‘Simples’;
app.optEspecies.Position = [11 3 64 22];
app.optEspecies.Value = true;
% Create optSimples
app.optSimples = uiradiobutton(app.btnTipoSegmentacao);
app.optSimples.Enable = ‘off’;
app.optSimples.Text = ‘Espécies’;
app.optSimples.Position = [103 3 70 22];
% Create RightPanel
app.RightPanel = uipanel(app.GridLayout);
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
% Create TabGroup
app.TabGroup = uitabgroup(app.RightPanel);
app.TabGroup.AutoResizeChildren = ‘off’;
app.TabGroup.Position = [11 65 467 325];
% Create IMAGEMTab
app.IMAGEMTab = uitab(app.TabGroup);
app.IMAGEMTab.AutoResizeChildren = ‘off’;
app.IMAGEMTab.Title = ‘IMAGEM’;
% Create panelImagem
app.panelImagem = uipanel(app.IMAGEMTab);
app.panelImagem.AutoResizeChildren = ‘off’;
app.panelImagem.BorderType = ‘none’;
app.panelImagem.Position = [8 8 452 284];
% Create plotImagem
app.plotImagem = uiaxes(app.panelImagem);
app.plotImagem.XTick = [];
app.plotImagem.YTick = [];
app.plotImagem.ZTick = [];
app.plotImagem.Color = [0.9412 0.9412 0.9412];
app.plotImagem.Box = ‘on’;
app.plotImagem.Position = [6 8 437 271];
% Create HISTOGRAMATab
app.HISTOGRAMATab = uitab(app.TabGroup);
app.HISTOGRAMATab.AutoResizeChildren = ‘off’;
app.HISTOGRAMATab.Title = ‘HISTOGRAMA’;
% Create panelHistogram
app.panelHistogram = uipanel(app.HISTOGRAMATab);
app.panelHistogram.AutoResizeChildren = ‘off’;
app.panelHistogram.BorderType = ‘none’;
app.panelHistogram.Position = [8 8 452 284];
% Create plotHistograma
app.plotHistograma = uiaxes(app.panelHistogram);
title(app.plotHistograma, ‘Frequência por Espécies’)
xlabel(app.plotHistograma, ‘Espécies de Palmeiras’)
ylabel(app.plotHistograma, ‘Nr. Pixels’)
app.plotHistograma.Toolbar.Visible = ‘off’;
app.plotHistograma.Box = ‘on’;
app.plotHistograma.XGrid = ‘on’;
app.plotHistograma.YGrid = ‘on’;
app.plotHistograma.Position = [6 8 437 271];
% Create AJUDASUPORTETab
app.AJUDASUPORTETab = uitab(app.TabGroup);
app.AJUDASUPORTETab.AutoResizeChildren = ‘off’;
app.AJUDASUPORTETab.Title = ‘AJUDA / SUPORTE’;
% Create HTML
app.HTML = uihtml(app.AJUDASUPORTETab);
app.HTML.HTMLSource = ‘suporte.html’;
app.HTML.Position = [15 14 435 272];
% Create panelBotoes
app.panelBotoes = uipanel(app.RightPanel);
app.panelBotoes.BorderType = ‘none’;
app.panelBotoes.Position = [12 7 465 48];
% Create btnCarregarImg
app.btnCarregarImg = uibutton(app.panelBotoes, ‘push’);
app.btnCarregarImg.ButtonPushedFcn = createCallbackFcn(app, @btnCarregarImgButtonPushed, true);
app.btnCarregarImg.WordWrap = ‘on’;
app.btnCarregarImg.Position = [21 8 91 35];
app.btnCarregarImg.Text = ‘Carregar Imagem…’;
% Create btnProcessar
app.btnProcessar = uibutton(app.panelBotoes, ‘push’);
app.btnProcessar.ButtonPushedFcn = createCallbackFcn(app, @btnProcessarButtonPushed, true);
app.btnProcessar.WordWrap = ‘on’;
app.btnProcessar.Enable = ‘off’;
app.btnProcessar.Position = [132 8 91 35];
app.btnProcessar.Text = ‘Processar Segmentação’;
% Create btnHistograma
app.btnHistograma = uibutton(app.panelBotoes, ‘push’);
app.btnHistograma.ButtonPushedFcn = createCallbackFcn(app, @btnHistogramaButtonPushed, true);
app.btnHistograma.WordWrap = ‘on’;
app.btnHistograma.Enable = ‘off’;
app.btnHistograma.Position = [243 8 91 35];
app.btnHistograma.Text = ‘Histograma’;
% Create btnExportar
app.btnExportar = uibutton(app.panelBotoes, ‘push’);
app.btnExportar.ButtonPushedFcn = createCallbackFcn(app, @btnExportarButtonPushed, true);
app.btnExportar.WordWrap = ‘on’;
app.btnExportar.Enable = ‘off’;
app.btnExportar.Position = [354 8 91 35];
app.btnExportar.Text = ‘Exportar Segmentação’;
% Show the figure after all components are created
app.UIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = segmentacao_palmeiras_tab_exported
runningApp = getRunningApp(app);
% Check for running singleton app
if isempty(runningApp)
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
else
% Focus the running singleton app
figure(runningApp.UIFigure)
app = runningApp;
end
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end
Could someone please help me resolve this issue?
Best regards,
Airton Gaio Jr. Hello everyone,
I have a small application built in MATLAB APP DESIGNER. It is divided into a 2-PANEL APP (Left and Right). In the Right PANEL, there is a TABGROUP component that contains three TABS: IMAGE; HISTOGRAM; and HELP / SUPPORT, as shown in the figure below:
Inside each TAB, there is a PANEL component, and within each PANEL, I have AXES components for the IMAGE and HISTOGRAM TABS. Everything works fine until I add an HTML component inside the PANEL of the HELP / SUPPORT TAB, which will display a page with information about the application. When I do this, the other components become disorganized, as shown in the figure below.
Below, the figures demonstrate the disorganization of the components in the IMAGE and HISTOGRAM TABS.
Attached is the application code:
classdef segmentacao_palmeiras_tab_exported < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
GridLayout matlab.ui.container.GridLayout
LeftPanel matlab.ui.container.Panel
panelInfo matlab.ui.container.Panel
btnTipoSegmentacao matlab.ui.container.ButtonGroup
optSimples matlab.ui.control.RadioButton
optEspecies matlab.ui.control.RadioButton
txt_InfoGeo matlab.ui.control.Label
lbl_InfoGeo matlab.ui.control.Label
txt_InfoDim matlab.ui.control.Label
lbl_InfoDim matlab.ui.control.Label
txt_InfoLocal matlab.ui.control.Label
lbl_InfoLocal matlab.ui.control.Label
lbl_InfoImagem matlab.ui.control.Label
logoINPA matlab.ui.control.Image
logoUDESC matlab.ui.control.Image
RightPanel matlab.ui.container.Panel
panelBotoes matlab.ui.container.Panel
btnExportar matlab.ui.control.Button
btnHistograma matlab.ui.control.Button
btnProcessar matlab.ui.control.Button
btnCarregarImg matlab.ui.control.Button
TabGroup matlab.ui.container.TabGroup
IMAGEMTab matlab.ui.container.Tab
panelImagem matlab.ui.container.Panel
plotImagem matlab.ui.control.UIAxes
HISTOGRAMATab matlab.ui.container.Tab
panelHistogram matlab.ui.container.Panel
plotHistograma matlab.ui.control.UIAxes
AJUDASUPORTETab matlab.ui.container.Tab
HTML matlab.ui.control.HTML
end
% Properties that correspond to apps with auto-reflow
properties (Access = private)
onePanelWidth = 576;
end
properties (Access = private)
ImageFile % Arquivo de imagem;
ImageFile_pad % Arquivo de imagem ajustado
C_Categorical % Resultado gerado em CATEGORICAL
C_Categorical_Simples % Resultado gerado em CATEGORICAL
C_Uint8 % Resultado gerado em UINT8
C_Uint8_Simples % Resultado gerado em UINT8
B % Overlay da Imagem com o Resultado Espécies
B_Simples % Overlay da Imagem com o Resultado Simples
H % Grafico do Histograma
NetWork % Rede Neural
ImageFile_x % Largura
ImageFile_y % Altura
ImageFile_dim % Nr. Bandas
ImageFile_format % Formato do arquivo
R % Referencia Espacial da Imagem
S % Dados Geográficos geotiffinfo
X % Dados Geográficos struct.geotiffinfo
end
methods (Access = private)
% Tela de Progresso
function d = myprogress(app)
d = uiprogressdlg(app.UIFigure,’Title’,’Por favor aguarde…’,…
‘Message’,’Abrindo a aplicação’);
pause(.5);
d.Value = .33;
d.Message = ‘Carregando os dados necessários’;
pause(1);
d.Value = .67;
d.Message = ‘Processando os dados’;
pause(1);
d.Value = 1;
d.Message = ‘Finalizando’;
pause(1);
% Fecha dialog box
close(d);
end
function resetApp(app)
% Limpar as variáveis
clear;
% Limpar todas as propriedades
app.ImageFile = [];
app.ImageFile_pad = [];
app.C_Categorical = [];
app.C_Categorical_Simples = [];
app.C_Uint8 = [];
app.C_Uint8_Simples = [];
app.B = [];
app.B_Simples = [];
app.H = [];
app.NetWork = [];
app.ImageFile_x = [];
app.ImageFile_y = [];
app.ImageFile_dim = [];
app.ImageFile_format = [];
app.R = [];
app.S = [];
app.X = [];
% Limpar componentes de UI
%cla(app.plotImagem);
%cla(app.plotHistograma);
end
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
app.UIFigure.Position = [100 100 1100 630]; % [x y width height]
app.UIFigure.Resize = ‘off’;
% Especifica o diretório da exportacao
diretorio = ‘export’;
% Verifica se o diretório existe
if ~isfolder(diretorio)
% Se o diretório não existe, cria o diretório
mkdir(diretorio);
end
% Desabilita/Habilita os botões
app.btnCarregarImg.Enable = true;
app.btnProcessar.Enable = false;
app.btnHistograma.Enable = false;
app.btnExportar.Enable = false;
% Desabilita os tipos de segmentação
app.btnTipoSegmentacao.Enable = true;
app.optEspecies.Enable = false;
app.optSimples.Enable = false;
% Carregando a rede treinada
try
load(‘./net_cocao.mat’,’net_cocao’);
app.NetWork = net_cocao;
catch ME
report = getReport(ME);
uialert(app.UIFigure,report,’Erro’,’Interpreter’,’html’);
end
end
% Button pushed function: btnCarregarImg
function btnCarregarImgButtonPushed(app, event)
% Limpa a variaveis, propriedades e visualizadores.
app.resetApp();
% Desabilita/Habilita os botões
app.btnProcessar.Enable = false;
app.btnHistograma.Enable = false;
app.btnExportar.Enable = false;
% Desabilita os tipos de segmentação
app.btnTipoSegmentacao.Enable = true;
app.optSimples.Value = 0;
app.optEspecies.Enable = false;
app.optSimples.Enable = false;
% Chama a janela para carregar a imagem
% Armazena os dados da imagem do usuario
[filename,filepath] = uigetfile({‘*.tif’}, ‘Selecionar imagem’);
fullname = [filepath, filename];
% Abre a imagem de entrada selecionada pelo usuário
app.ImageFile = imread(fullname);
app.myprogress;
% Armazena informações sobre dimensões da imagem de entrada
[app.ImageFile_x,app.ImageFile_y,app.ImageFile_dim] = size(app.ImageFile);
% Armazena as informações geográficas da Imagem carregada
[~, r] = readgeoraster(fullname);
app.R = r;
app.X = geotiffinfo(fullname);
app.S = struct([app.X.GeoTIFFTags.GeoKeyDirectoryTag]);
app.ImageFile_format = app.X.Format;
% Verifica se o formato da imagem é TIF
if (string(app.ImageFile_format) ~= ‘tif’)
msg = {‘ATENÇÃO!’,’O formato da imagem deve ser TIF.’};
uialert(app.UIFigure,msg,’Warning’,’Icon’,’warning’);
end
% Verifica se o numero de bandas estão
% corretos para utilizar no programa.
if (app.ImageFile_dim ~= 3)
% Para o caso da imagem I tenha mais de 3 bandas deve-se retirar deixando
% somente 3 bandas
% Isolar as bandas da imagem
B1 = app.ImageFile(:,:,1);
B2 = app.ImageFile(:,:,2);
B3 = app.ImageFile(:,:,3);
% Junta as bandas isoladas
app.ImageFile = cat(3, B1, B2, B3);
msg = {‘ATENÇÃO!’,’A imagem de entrada deve ter 3 bandas. A imagem carregada engloba mais de 3 bandas. Foram consideradas somente as 3 primeiras bandas para o processamento.’};
uialert(app.UIFigure,msg,’Aviso’,’Icon’,’warning’);
end
% Ajustar a escala da imgem para a segmentação conforme o
% treinamento feito na CNN 512×512 pixels.
PatchSize = [512, 512];
app.ImageFile = imresize(app.ImageFile,’Scale’, PatchSize ./ 512);
% Apresenta a imagem no applicativo (Plot)
imshow(app.ImageFile,’Parent’,app.plotImagem);
%imagesc(app.plotImagem, app.ImageFile);
% Mostra as informaçções de tamanho e dimensão da imagem
%informacoes = sprintf(‘Arquivo: %ssprintf(‘Arquivo: %sn Tamanho (Bytes): %sn Altura: %sn Largula: %sn Nr. Bandas: %sn DATUM/Projeção: %sn’,app.X.Filename, app.X.FileSize, app.X.Height, app.X.Width, app.ImageFile_dim, app.X.PCS);n Altura: %sn Largula: %sn Nr. Bandas: %sn DATUM/Projeção: %sn’,app.X.Filename, app.X.FileSize, app.X.Height, app.X.Width, app.ImageFile_dim, app.X.PCS);
%app.txt_InfoLocal.Text = string(informacoes);
app.txt_InfoLocal.Text = string(app.X.Filename);
altura = string("Altura: " + app.X.Height);
largura = string("Largura: " + app.X.Width);
nr_dim = string("Nr. Bandas: " + app.ImageFile_dim);
tamanho = string("Tamanho (Bytes): " + app.X.FileSize);
dimensoes = [altura, largura, nr_dim, tamanho];
app.txt_InfoDim.Text = dimensoes;
app.txt_InfoGeo.Text = string(app.X.PCS);
% Desabilita/Habilita os botões
app.btnProcessar.Enable = true;
app.TabGroup.SelectedTab = app.IMAGEMTab;
end
% Button pushed function: btnProcessar
function btnProcessarButtonPushed(app, event)
% Desabilita o botão de Exportar/Carregar até o termino do processamento
app.btnCarregarImg.Enable = false;
app.btnExportar.Enable = false;
app.btnHistograma.Enable = false;
% Verifica se a GPU está disponível
useGPU = canUseGPU();
if useGPU
% Limpa a Memoria da GPU antes do processamento
D = gpuDevice();
reset(D);
end
% Cria a função para processar imagens de tamanho grandes por
% blocos
if useGPU
fun_proc_semanticseg = @(bloco)semanticseg(bloco.data, app.NetWork,ExecutionEnvironment="gpu",MiniBatchSize=16,OutputType="uint8",Acceleration="auto");
else
fun_proc_semanticseg = @(bloco)semanticseg(bloco.data, app.NetWork,ExecutionEnvironment="auto",MiniBatchSize=16,OutputType="uint8",Acceleration="auto");
end
% Redefine o tamanho do bloco para 512
tamanho_bloco = [512 512];
% Armazena o tamanho da imagem I
[height, width, ~] = size(app.ImageFile);
% Calcula o pad image para obter a dimensão que seja multiplo de tamanho do bloco
padSize(1) = tamanho_bloco(1) – mod(height, tamanho_bloco(1));
padSize(2) = tamanho_bloco(2) – mod(width, tamanho_bloco(2));
% Gera uma cópia da imagem com o tamanho adequado para o tamanho do Bloco.
% o tamanho acrestado (PAD) a imagem é preenchido com valor 0
app.ImageFile_pad = padarray(app.ImageFile, padSize, 0, ‘post’);
% Processa a segmentação
try
% Redefine o tamanho do bloco para 2048
tamanho_bloco = [2048 2048];
C = blockproc(app.ImageFile_pad, tamanho_bloco, fun_proc_semanticseg);
app.myprogress;
% The output is nosy, apply a median filter to remove spurious pixels.
C = medfilt2(C,[5 5]);
% Retorna o resultado para o tamanho original
C = C(1:height, 1:width);
C = changem(C,7,0);
catch ME
report = getReport(ME);
uialert(app.UIFigure,report,’Erro’,’Interpreter’,’html’);
end
% Definição dos Valores e Nome das Classes (ESPECIES)
labelIDs = [1 2 3 4 5 6 7];
classes = ["Açai" "Cocão" "Jaci" "Paxiuba" "Tucuma" "Floresta" "no-data"];
% Definição dos Valores e Nome das Classes (SIMPLES)
labelIDs_Simples = [1 2 3];
classes_Simples = ["Palmeiras" "Floresta" "no-data"];
% Alterar a segmentacao de ESPECIES -> SIMPLES
C_Simples = C;
C_Simples = changem(C_Simples,3,0);
C_Simples = changem(C_Simples,1,2);
C_Simples = changem(C_Simples,1,3);
C_Simples = changem(C_Simples,1,4);
C_Simples = changem(C_Simples,1,5);
C_Simples = changem(C_Simples,2,6);
C_Simples = changem(C_Simples,3,7);
% Converte a saida da segmentação de UINT8 para Categorical
% possibilitando a exportação.
app.C_Categorical = categorical(C, labelIDs, classes);
app.C_Uint8 = C;
app.C_Categorical_Simples = categorical(C_Simples,labelIDs_Simples,classes_Simples);
app.C_Uint8_Simples = C_Simples;
app.B = labeloverlay(app.ImageFile,C);
app.B_Simples = labeloverlay(app.ImageFile,C_Simples);
% Monta a sobreposição da Imagem com o resultado gerado da
% segmentação
if app.optSimples.Value ~= 1
% Apresenta o resultado da segmentação no applicativo (Plot)
%imagesc(app.plotImagem, B);
imshow(app.B_Simples,’Parent’,app.plotImagem);
%app.TabGroup.SelectedTab = app.IMAGEMTab;
else % Espécie
% Apresenta o resultado da segmentação no applicativo (Plot)
%imagesc(app.plotImagem, B);
imshow(app.B,’Parent’,app.plotImagem);
%app.TabGroup.SelectedTab = app.IMAGEMTab;
end
% Habilita o botão de Exportar/Carregar até o termino do processamento
app.btnCarregarImg.Enable = true;
app.btnHistograma.Enable = true;
app.btnExportar.Enable = true;
app.btnProcessar.Enable = false;
% Habilita os tipos de segmentação
app.btnTipoSegmentacao.Enable = true;
app.optEspecies.Enable = true;
app.optSimples.Enable = true;
end
% Button pushed function: btnExportar
function btnExportarButtonPushed(app, event)
% Habilita o botão de Exportar/Carregar até o termino do processamento
app.btnCarregarImg.Enable = false;
app.btnHistograma.Enable = false;
app.btnProcessar.Enable = false;
% Processa a exportação do resultado da segmentação
try
if app.optSimples.Value ~= 1
geotiffwrite(‘./export/classImg.tif’,app.C_Uint8_Simples,app.R,’GeoKeyDirectoryTag’,app.S);
app.myprogress;
else
geotiffwrite(‘./export/classImg.tif’,app.C_Uint8,app.R,’GeoKeyDirectoryTag’,app.S);
app.myprogress;
end
message = ["Resultado Exportado!","Procure o arquivo classImg.tif na pasta export."];
uialert(app.UIFigure,message,"Sucesso", "Icon","success");
catch ME
report = getReport(ME);
uialert(app.UIFigure,report,’Erro’,’Interpreter’,’html’);
end
% Habilita o botão de Exportar/Carregar até o termino do processamento
app.btnCarregarImg.Enable = true;
app.btnHistograma.Enable = true;
app.btnExportar.Enable = true;
app.btnProcessar.Enable = false;
end
% Button pushed function: btnHistograma
function btnHistogramaButtonPushed(app, event)
% Processa o histograma do resultado da segmentação
try
% histograma.
if app.optSimples.Value ~= 1
app.H = histogram(app.plotHistograma,app.C_Categorical_Simples …
,"FaceColor",[1 0 0],"EdgeColor","none");
else % Espécie
app.H = histogram(app.plotHistograma,app.C_Categorical …
,"FaceColor",[1 0 0],"EdgeColor","none");
end
catch ME
report = getReport(ME);
uialert(app.UIFigure,report,’Erro’,’Interpreter’,’html’);
end
app.TabGroup.SelectedTab = app.HISTOGRAMATab;
end
% Selection changed function: btnTipoSegmentacao
function btnTipoSegmentacaoSelectionChanged(app, event)
% Escolheu o Tipo Simples
if app.optSimples.Value ~= 1
imshow(app.B_Simples,’Parent’,app.plotImagem);
app.TabGroup.SelectedTab = app.IMAGEMTab;
% Verifica se existe o histograma
if isprop(app, ‘H’) && ~isempty(app.H)
app.H = histogram(app.plotHistograma, app.C_Categorical_Simples, …
‘FaceColor’, [1 0 0], ‘EdgeColor’, ‘none’);
end
else % Espécies
imshow(app.B,’Parent’,app.plotImagem);
app.TabGroup.SelectedTab = app.IMAGEMTab;
% Verifica se existe o histograma
if isprop(app, ‘H’) && ~isempty(app.H)
app.H = histogram(app.plotHistograma, app.C_Categorical, …
‘FaceColor’, [1 0 0], ‘EdgeColor’, ‘none’);
end
end
end
% Changes arrangement of the app based on UIFigure width
function updateAppLayout(app, event)
currentFigureWidth = app.UIFigure.Position(3);
if(currentFigureWidth <= app.onePanelWidth)
% Change to a 2×1 grid
app.GridLayout.RowHeight = {397, 397};
app.GridLayout.ColumnWidth = {‘1x’};
app.RightPanel.Layout.Row = 2;
app.RightPanel.Layout.Column = 1;
else
% Change to a 1×2 grid
app.GridLayout.RowHeight = {‘1x’};
app.GridLayout.ColumnWidth = {212, ‘1x’};
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
end
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Get the file path for locating images
pathToMLAPP = fileparts(mfilename(‘fullpath’));
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure(‘Visible’, ‘off’);
app.UIFigure.AutoResizeChildren = ‘off’;
app.UIFigure.Position = [100 100 698 397];
app.UIFigure.Name = ‘MATLAB App’;
app.UIFigure.Resize = ‘off’;
app.UIFigure.SizeChangedFcn = createCallbackFcn(app, @updateAppLayout, true);
% Create GridLayout
app.GridLayout = uigridlayout(app.UIFigure);
app.GridLayout.ColumnWidth = {212, ‘1x’};
app.GridLayout.RowHeight = {‘1x’};
app.GridLayout.ColumnSpacing = 0;
app.GridLayout.RowSpacing = 0;
app.GridLayout.Padding = [0 0 0 0];
app.GridLayout.Scrollable = ‘on’;
% Create LeftPanel
app.LeftPanel = uipanel(app.GridLayout);
app.LeftPanel.Layout.Row = 1;
app.LeftPanel.Layout.Column = 1;
% Create panelInfo
app.panelInfo = uipanel(app.LeftPanel);
app.panelInfo.BorderType = ‘none’;
app.panelInfo.Position = [7 7 200 384];
% Create logoUDESC
app.logoUDESC = uiimage(app.panelInfo);
app.logoUDESC.Position = [8 345 83 34];
app.logoUDESC.ImageSource = fullfile(pathToMLAPP, ‘udesc2_logo.png’);
% Create logoINPA
app.logoINPA = uiimage(app.panelInfo);
app.logoINPA.Position = [110 346 83 34];
app.logoINPA.ImageSource = fullfile(pathToMLAPP, ‘inpa-acre_logo.png’);
% Create lbl_InfoImagem
app.lbl_InfoImagem = uilabel(app.panelInfo);
app.lbl_InfoImagem.HorizontalAlignment = ‘center’;
app.lbl_InfoImagem.FontSize = 14;
app.lbl_InfoImagem.FontWeight = ‘bold’;
app.lbl_InfoImagem.Position = [7 315 186 22];
app.lbl_InfoImagem.Text = ‘Informações da Entrada’;
% Create lbl_InfoLocal
app.lbl_InfoLocal = uilabel(app.panelInfo);
app.lbl_InfoLocal.FontWeight = ‘bold’;
app.lbl_InfoLocal.Position = [7 287 186 22];
app.lbl_InfoLocal.Text = ‘Local:’;
% Create txt_InfoLocal
app.txt_InfoLocal = uilabel(app.panelInfo);
app.txt_InfoLocal.VerticalAlignment = ‘top’;
app.txt_InfoLocal.WordWrap = ‘on’;
app.txt_InfoLocal.FontSize = 9;
app.txt_InfoLocal.Position = [7 246 186 34];
app.txt_InfoLocal.Text = ‘ ‘;
% Create lbl_InfoDim
app.lbl_InfoDim = uilabel(app.panelInfo);
app.lbl_InfoDim.FontWeight = ‘bold’;
app.lbl_InfoDim.Position = [7 218 186 22];
app.lbl_InfoDim.Text = ‘Dimensão:’;
% Create txt_InfoDim
app.txt_InfoDim = uilabel(app.panelInfo);
app.txt_InfoDim.VerticalAlignment = ‘top’;
app.txt_InfoDim.WordWrap = ‘on’;
app.txt_InfoDim.FontSize = 9;
app.txt_InfoDim.Position = [7 131 186 80];
app.txt_InfoDim.Text = ‘ ‘;
% Create lbl_InfoGeo
app.lbl_InfoGeo = uilabel(app.panelInfo);
app.lbl_InfoGeo.FontWeight = ‘bold’;
app.lbl_InfoGeo.Position = [7 106 186 22];
app.lbl_InfoGeo.Text = ‘Dados Geográficos:’;
% Create txt_InfoGeo
app.txt_InfoGeo = uilabel(app.panelInfo);
app.txt_InfoGeo.VerticalAlignment = ‘top’;
app.txt_InfoGeo.WordWrap = ‘on’;
app.txt_InfoGeo.FontSize = 9;
app.txt_InfoGeo.Position = [7 65 186 34];
app.txt_InfoGeo.Text = ‘ ‘;
% Create btnTipoSegmentacao
app.btnTipoSegmentacao = uibuttongroup(app.panelInfo);
app.btnTipoSegmentacao.SelectionChangedFcn = createCallbackFcn(app, @btnTipoSegmentacaoSelectionChanged, true);
app.btnTipoSegmentacao.Title = ‘Tipo de Segmentação:’;
app.btnTipoSegmentacao.Position = [6 10 186 49];
% Create optEspecies
app.optEspecies = uiradiobutton(app.btnTipoSegmentacao);
app.optEspecies.Enable = ‘off’;
app.optEspecies.Text = ‘Simples’;
app.optEspecies.Position = [11 3 64 22];
app.optEspecies.Value = true;
% Create optSimples
app.optSimples = uiradiobutton(app.btnTipoSegmentacao);
app.optSimples.Enable = ‘off’;
app.optSimples.Text = ‘Espécies’;
app.optSimples.Position = [103 3 70 22];
% Create RightPanel
app.RightPanel = uipanel(app.GridLayout);
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
% Create TabGroup
app.TabGroup = uitabgroup(app.RightPanel);
app.TabGroup.AutoResizeChildren = ‘off’;
app.TabGroup.Position = [11 65 467 325];
% Create IMAGEMTab
app.IMAGEMTab = uitab(app.TabGroup);
app.IMAGEMTab.AutoResizeChildren = ‘off’;
app.IMAGEMTab.Title = ‘IMAGEM’;
% Create panelImagem
app.panelImagem = uipanel(app.IMAGEMTab);
app.panelImagem.AutoResizeChildren = ‘off’;
app.panelImagem.BorderType = ‘none’;
app.panelImagem.Position = [8 8 452 284];
% Create plotImagem
app.plotImagem = uiaxes(app.panelImagem);
app.plotImagem.XTick = [];
app.plotImagem.YTick = [];
app.plotImagem.ZTick = [];
app.plotImagem.Color = [0.9412 0.9412 0.9412];
app.plotImagem.Box = ‘on’;
app.plotImagem.Position = [6 8 437 271];
% Create HISTOGRAMATab
app.HISTOGRAMATab = uitab(app.TabGroup);
app.HISTOGRAMATab.AutoResizeChildren = ‘off’;
app.HISTOGRAMATab.Title = ‘HISTOGRAMA’;
% Create panelHistogram
app.panelHistogram = uipanel(app.HISTOGRAMATab);
app.panelHistogram.AutoResizeChildren = ‘off’;
app.panelHistogram.BorderType = ‘none’;
app.panelHistogram.Position = [8 8 452 284];
% Create plotHistograma
app.plotHistograma = uiaxes(app.panelHistogram);
title(app.plotHistograma, ‘Frequência por Espécies’)
xlabel(app.plotHistograma, ‘Espécies de Palmeiras’)
ylabel(app.plotHistograma, ‘Nr. Pixels’)
app.plotHistograma.Toolbar.Visible = ‘off’;
app.plotHistograma.Box = ‘on’;
app.plotHistograma.XGrid = ‘on’;
app.plotHistograma.YGrid = ‘on’;
app.plotHistograma.Position = [6 8 437 271];
% Create AJUDASUPORTETab
app.AJUDASUPORTETab = uitab(app.TabGroup);
app.AJUDASUPORTETab.AutoResizeChildren = ‘off’;
app.AJUDASUPORTETab.Title = ‘AJUDA / SUPORTE’;
% Create HTML
app.HTML = uihtml(app.AJUDASUPORTETab);
app.HTML.HTMLSource = ‘suporte.html’;
app.HTML.Position = [15 14 435 272];
% Create panelBotoes
app.panelBotoes = uipanel(app.RightPanel);
app.panelBotoes.BorderType = ‘none’;
app.panelBotoes.Position = [12 7 465 48];
% Create btnCarregarImg
app.btnCarregarImg = uibutton(app.panelBotoes, ‘push’);
app.btnCarregarImg.ButtonPushedFcn = createCallbackFcn(app, @btnCarregarImgButtonPushed, true);
app.btnCarregarImg.WordWrap = ‘on’;
app.btnCarregarImg.Position = [21 8 91 35];
app.btnCarregarImg.Text = ‘Carregar Imagem…’;
% Create btnProcessar
app.btnProcessar = uibutton(app.panelBotoes, ‘push’);
app.btnProcessar.ButtonPushedFcn = createCallbackFcn(app, @btnProcessarButtonPushed, true);
app.btnProcessar.WordWrap = ‘on’;
app.btnProcessar.Enable = ‘off’;
app.btnProcessar.Position = [132 8 91 35];
app.btnProcessar.Text = ‘Processar Segmentação’;
% Create btnHistograma
app.btnHistograma = uibutton(app.panelBotoes, ‘push’);
app.btnHistograma.ButtonPushedFcn = createCallbackFcn(app, @btnHistogramaButtonPushed, true);
app.btnHistograma.WordWrap = ‘on’;
app.btnHistograma.Enable = ‘off’;
app.btnHistograma.Position = [243 8 91 35];
app.btnHistograma.Text = ‘Histograma’;
% Create btnExportar
app.btnExportar = uibutton(app.panelBotoes, ‘push’);
app.btnExportar.ButtonPushedFcn = createCallbackFcn(app, @btnExportarButtonPushed, true);
app.btnExportar.WordWrap = ‘on’;
app.btnExportar.Enable = ‘off’;
app.btnExportar.Position = [354 8 91 35];
app.btnExportar.Text = ‘Exportar Segmentação’;
% Show the figure after all components are created
app.UIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = segmentacao_palmeiras_tab_exported
runningApp = getRunningApp(app);
% Check for running singleton app
if isempty(runningApp)
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
else
% Focus the running singleton app
figure(runningApp.UIFigure)
app = runningApp;
end
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end
Could someone please help me resolve this issue?
Best regards,
Airton Gaio Jr. app designer, disorganization, components html, components axes MATLAB Answers — New Questions
Programmatically get all block parameters
Some blocks have special parameters, that are not listed in
get_parameter(block, ‘DialogParameters’)
get_parameter(block, ‘ObjectParamters’)
For example, the MATLAB function block reveals its content with the object in
get_param(block, ‘MATLABFunctionConfiguration’)
Which is listed in neither. How to get a list of all a block’s parameters, even exotic ones? Is there maybe a block object to circumvent such an awkward search, for specific parameters you don’t even know exist?Some blocks have special parameters, that are not listed in
get_parameter(block, ‘DialogParameters’)
get_parameter(block, ‘ObjectParamters’)
For example, the MATLAB function block reveals its content with the object in
get_param(block, ‘MATLABFunctionConfiguration’)
Which is listed in neither. How to get a list of all a block’s parameters, even exotic ones? Is there maybe a block object to circumvent such an awkward search, for specific parameters you don’t even know exist? Some blocks have special parameters, that are not listed in
get_parameter(block, ‘DialogParameters’)
get_parameter(block, ‘ObjectParamters’)
For example, the MATLAB function block reveals its content with the object in
get_param(block, ‘MATLABFunctionConfiguration’)
Which is listed in neither. How to get a list of all a block’s parameters, even exotic ones? Is there maybe a block object to circumvent such an awkward search, for specific parameters you don’t even know exist? get_param, hidden, block, parameters MATLAB Answers — New Questions
Simulink – STM32 – PIL test communication error
I have a Simulink model that contain an algorithm block. I built the generated c code succesfully to STM32F4-discovery board. (I read that from diagnostic viewer.) I used SIL/PIL Manager App to make PIL test. I selected serial communication at configuration panel. When I run the PIL simulation I get this error:
The timeout of 10 seconds for receiving data from the rtiostream interface has been exceeded. There might be multiple reasons for this communications failure. You should:
(a) Check that the target hardware configuration is correct, for example, check that the byte ordering is correct.
(b) Confirm that the target application is running on the target hardware.
(c) Consider the possibility of application run-time failures (e.g. divide by zero exceptions, incorrect custom code integration, etc.).
Note (c): To identify possible reasons for the run-time failure, consider using SIL, which supports signal handlers and debugging. If you cannot find a solution, consider using the method setTimeoutRecvSecs of rtw.connectivity.RtIOStreamHostCommunicator to increase the timeout value.
This is my example model:
This is the diagnostic viewer outputs:
### Connectivity configuration for "C:UsersatakanDesktopmilpilsilmult_ert_rtw": STM32F4-Discovery (Serial) ###
### Preparing to start PIL block simulation: denemepil/mult …
### Using toolchain: GNU Tools for ARM Embedded Processors
### ‘C:UsersatakanDesktopmilpilsilmult_ert_rtwpilmult.mk’ is up to date
### Building ‘mult’: "D:MATLABbinwin64gmake" -f mult.mk all MW_GNU_ARM_TOOLS_PATH = C:/PROGRA~3/MATLAB/SUPPOR~1/R2020b/3P778C~1.INS/GNUARM~1.INS/win/bin C:UsersatakanDesktopmilpilsilmult_ert_rtwpil>cd . C:UsersatakanDesktopmilpilsilmult_ert_rtwpil>if "" == "" ("D:MATLABbinwin64gmake" -f mult.mk all ) else ("D:MATLABbinwin64gmake" -f mult.mk )
"### Invoking postbuild tool "Binary Converter" …" "C:/PROGRA~3/MATLAB/SUPPOR~1/R2020b/3P778C~1.INS/GNUARM~1.INS/win/bin/arm-none-eabi-objcopy" -O binary ./mult.elf ../../mult.bin
"### Done invoking postbuild tool."
"### Invoking postbuild tool "Hex Converter" …" "C:/PROGRA~3/MATLAB/SUPPOR~1/R2020b/3P778C~1.INS/GNUARM~1.INS/win/bin/arm-none-eabi-objcopy" -O ihex ./mult.elf ../../mult.hex
"### Done invoking postbuild tool."
"### Invoking postbuild tool "Executable Size" …" "C:/PROGRA~3/MATLAB/SUPPOR~1/R2020b/3P778C~1.INS/GNUARM~1.INS/win/bin/arm-none-eabi-size" ./mult.elf text data bss dec hex filename 16748 160 12016 28924 70fc ./mult.elf
"### Done invoking postbuild tool."
"### Successfully generated all binary outputs." C:UsersatakanDesktopmilpilsilmult_ert_rtwpil>exit 0
### Starting application: ‘mult_ert_rtwpilmult.elf’
### Started new OpenOCD process with PID 19356.
### Terminated OpenOCD process with PID 19356.
The timeout of 10 seconds for receiving data from the rtiostream interface has been exceeded. There might be multiple reasons for this communications failure. You should: (a) Check that the target hardware configuration is correct, for example, check that the byte ordering is correct. (b) Confirm that the target application is running on the target hardware. (c) Consider the possibility of application run-time failures (e.g. divide by zero exceptions, incorrect custom code integration, etc.). Note (c): To identify possible reasons for the run-time failure, consider using SIL, which supports signal handlers and debugging. If you cannot find a solution, consider using the method setTimeoutRecvSecs of rtw.connectivity.RtIOStreamHostCommunicator to increase the timeout value.
How can I fix this?I have a Simulink model that contain an algorithm block. I built the generated c code succesfully to STM32F4-discovery board. (I read that from diagnostic viewer.) I used SIL/PIL Manager App to make PIL test. I selected serial communication at configuration panel. When I run the PIL simulation I get this error:
The timeout of 10 seconds for receiving data from the rtiostream interface has been exceeded. There might be multiple reasons for this communications failure. You should:
(a) Check that the target hardware configuration is correct, for example, check that the byte ordering is correct.
(b) Confirm that the target application is running on the target hardware.
(c) Consider the possibility of application run-time failures (e.g. divide by zero exceptions, incorrect custom code integration, etc.).
Note (c): To identify possible reasons for the run-time failure, consider using SIL, which supports signal handlers and debugging. If you cannot find a solution, consider using the method setTimeoutRecvSecs of rtw.connectivity.RtIOStreamHostCommunicator to increase the timeout value.
This is my example model:
This is the diagnostic viewer outputs:
### Connectivity configuration for "C:UsersatakanDesktopmilpilsilmult_ert_rtw": STM32F4-Discovery (Serial) ###
### Preparing to start PIL block simulation: denemepil/mult …
### Using toolchain: GNU Tools for ARM Embedded Processors
### ‘C:UsersatakanDesktopmilpilsilmult_ert_rtwpilmult.mk’ is up to date
### Building ‘mult’: "D:MATLABbinwin64gmake" -f mult.mk all MW_GNU_ARM_TOOLS_PATH = C:/PROGRA~3/MATLAB/SUPPOR~1/R2020b/3P778C~1.INS/GNUARM~1.INS/win/bin C:UsersatakanDesktopmilpilsilmult_ert_rtwpil>cd . C:UsersatakanDesktopmilpilsilmult_ert_rtwpil>if "" == "" ("D:MATLABbinwin64gmake" -f mult.mk all ) else ("D:MATLABbinwin64gmake" -f mult.mk )
"### Invoking postbuild tool "Binary Converter" …" "C:/PROGRA~3/MATLAB/SUPPOR~1/R2020b/3P778C~1.INS/GNUARM~1.INS/win/bin/arm-none-eabi-objcopy" -O binary ./mult.elf ../../mult.bin
"### Done invoking postbuild tool."
"### Invoking postbuild tool "Hex Converter" …" "C:/PROGRA~3/MATLAB/SUPPOR~1/R2020b/3P778C~1.INS/GNUARM~1.INS/win/bin/arm-none-eabi-objcopy" -O ihex ./mult.elf ../../mult.hex
"### Done invoking postbuild tool."
"### Invoking postbuild tool "Executable Size" …" "C:/PROGRA~3/MATLAB/SUPPOR~1/R2020b/3P778C~1.INS/GNUARM~1.INS/win/bin/arm-none-eabi-size" ./mult.elf text data bss dec hex filename 16748 160 12016 28924 70fc ./mult.elf
"### Done invoking postbuild tool."
"### Successfully generated all binary outputs." C:UsersatakanDesktopmilpilsilmult_ert_rtwpil>exit 0
### Starting application: ‘mult_ert_rtwpilmult.elf’
### Started new OpenOCD process with PID 19356.
### Terminated OpenOCD process with PID 19356.
The timeout of 10 seconds for receiving data from the rtiostream interface has been exceeded. There might be multiple reasons for this communications failure. You should: (a) Check that the target hardware configuration is correct, for example, check that the byte ordering is correct. (b) Confirm that the target application is running on the target hardware. (c) Consider the possibility of application run-time failures (e.g. divide by zero exceptions, incorrect custom code integration, etc.). Note (c): To identify possible reasons for the run-time failure, consider using SIL, which supports signal handlers and debugging. If you cannot find a solution, consider using the method setTimeoutRecvSecs of rtw.connectivity.RtIOStreamHostCommunicator to increase the timeout value.
How can I fix this? I have a Simulink model that contain an algorithm block. I built the generated c code succesfully to STM32F4-discovery board. (I read that from diagnostic viewer.) I used SIL/PIL Manager App to make PIL test. I selected serial communication at configuration panel. When I run the PIL simulation I get this error:
The timeout of 10 seconds for receiving data from the rtiostream interface has been exceeded. There might be multiple reasons for this communications failure. You should:
(a) Check that the target hardware configuration is correct, for example, check that the byte ordering is correct.
(b) Confirm that the target application is running on the target hardware.
(c) Consider the possibility of application run-time failures (e.g. divide by zero exceptions, incorrect custom code integration, etc.).
Note (c): To identify possible reasons for the run-time failure, consider using SIL, which supports signal handlers and debugging. If you cannot find a solution, consider using the method setTimeoutRecvSecs of rtw.connectivity.RtIOStreamHostCommunicator to increase the timeout value.
This is my example model:
This is the diagnostic viewer outputs:
### Connectivity configuration for "C:UsersatakanDesktopmilpilsilmult_ert_rtw": STM32F4-Discovery (Serial) ###
### Preparing to start PIL block simulation: denemepil/mult …
### Using toolchain: GNU Tools for ARM Embedded Processors
### ‘C:UsersatakanDesktopmilpilsilmult_ert_rtwpilmult.mk’ is up to date
### Building ‘mult’: "D:MATLABbinwin64gmake" -f mult.mk all MW_GNU_ARM_TOOLS_PATH = C:/PROGRA~3/MATLAB/SUPPOR~1/R2020b/3P778C~1.INS/GNUARM~1.INS/win/bin C:UsersatakanDesktopmilpilsilmult_ert_rtwpil>cd . C:UsersatakanDesktopmilpilsilmult_ert_rtwpil>if "" == "" ("D:MATLABbinwin64gmake" -f mult.mk all ) else ("D:MATLABbinwin64gmake" -f mult.mk )
"### Invoking postbuild tool "Binary Converter" …" "C:/PROGRA~3/MATLAB/SUPPOR~1/R2020b/3P778C~1.INS/GNUARM~1.INS/win/bin/arm-none-eabi-objcopy" -O binary ./mult.elf ../../mult.bin
"### Done invoking postbuild tool."
"### Invoking postbuild tool "Hex Converter" …" "C:/PROGRA~3/MATLAB/SUPPOR~1/R2020b/3P778C~1.INS/GNUARM~1.INS/win/bin/arm-none-eabi-objcopy" -O ihex ./mult.elf ../../mult.hex
"### Done invoking postbuild tool."
"### Invoking postbuild tool "Executable Size" …" "C:/PROGRA~3/MATLAB/SUPPOR~1/R2020b/3P778C~1.INS/GNUARM~1.INS/win/bin/arm-none-eabi-size" ./mult.elf text data bss dec hex filename 16748 160 12016 28924 70fc ./mult.elf
"### Done invoking postbuild tool."
"### Successfully generated all binary outputs." C:UsersatakanDesktopmilpilsilmult_ert_rtwpil>exit 0
### Starting application: ‘mult_ert_rtwpilmult.elf’
### Started new OpenOCD process with PID 19356.
### Terminated OpenOCD process with PID 19356.
The timeout of 10 seconds for receiving data from the rtiostream interface has been exceeded. There might be multiple reasons for this communications failure. You should: (a) Check that the target hardware configuration is correct, for example, check that the byte ordering is correct. (b) Confirm that the target application is running on the target hardware. (c) Consider the possibility of application run-time failures (e.g. divide by zero exceptions, incorrect custom code integration, etc.). Note (c): To identify possible reasons for the run-time failure, consider using SIL, which supports signal handlers and debugging. If you cannot find a solution, consider using the method setTimeoutRecvSecs of rtw.connectivity.RtIOStreamHostCommunicator to increase the timeout value.
How can I fix this? embedded coder, pil, stm32f4, stm32, serial, processor in the loop, sil/pil manager MATLAB Answers — New Questions
Squizzed help display in File Exchange contribution tab
Hi all,
I am a contributor to the file exchange, and recently I noticed the help I provide with my file (‘doc.m’ compiled via the command publish(‘doc.m’); ) is now completely squizzed / shrinked in a scrolling menu which is less than an inch height.
You can see it in my MP toolbox here for instance, but also here and probably in all my files which have an help and maybe also in all the files of the Matlab file exchange.
Do you know how to fix / solve this and come back to the previous display ?
Thank you for your help.
Cheers,
NicolasHi all,
I am a contributor to the file exchange, and recently I noticed the help I provide with my file (‘doc.m’ compiled via the command publish(‘doc.m’); ) is now completely squizzed / shrinked in a scrolling menu which is less than an inch height.
You can see it in my MP toolbox here for instance, but also here and probably in all my files which have an help and maybe also in all the files of the Matlab file exchange.
Do you know how to fix / solve this and come back to the previous display ?
Thank you for your help.
Cheers,
Nicolas Hi all,
I am a contributor to the file exchange, and recently I noticed the help I provide with my file (‘doc.m’ compiled via the command publish(‘doc.m’); ) is now completely squizzed / shrinked in a scrolling menu which is less than an inch height.
You can see it in my MP toolbox here for instance, but also here and probably in all my files which have an help and maybe also in all the files of the Matlab file exchange.
Do you know how to fix / solve this and come back to the previous display ?
Thank you for your help.
Cheers,
Nicolas help, tab, fex, file, exchange, squizzed, shrinked, display MATLAB Answers — New Questions
What hardware Matlab Online uses?
I am trying to find what kind of resources Matlab Online uses, since I need to provide the environment for my project, but I can’t find it anywhere. Does anyone know what kind of hardware resources Matlab Online uses?I am trying to find what kind of resources Matlab Online uses, since I need to provide the environment for my project, but I can’t find it anywhere. Does anyone know what kind of hardware resources Matlab Online uses? I am trying to find what kind of resources Matlab Online uses, since I need to provide the environment for my project, but I can’t find it anywhere. Does anyone know what kind of hardware resources Matlab Online uses? hardware, matlab online MATLAB Answers — New Questions
Can’t load datasets in EEGLAB using script
I’m trying to create a loop that can load and preprocess EEG data sets, here is my code and the reoccuring error
[ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, 0 );
%% Get the list of subjects to load:
dataset = uigetdir;%allows user to manually select the folder where the data sets are stored
subjectlist = dir(dataset);
subjectlist = subjectlist(~ismember({subjectlist.name},{‘.’,’..’}));
SUB = {subjectlist(:).name};
filepath = {subjectlist(:).folder};
%%
%load data
for i = 1 : length(SUB)
% 0. Select subject id:
%subject = subjectlist(i);
% Print info to the command window
% display(‘Processing Subject %sn’, SUB(i));
%Define subject path based on study directory and subject ID of current subject
Subject_Path = filepath{i};
Subject_Path = convertCharsToStrings(Subject_Path);
% 1. Load subject data:
% subject_data = load_subject_data(cfg,subject);
[ALLEEG EEG CURRENTSET ALLCOM] = eeglab;
EEG = pop_loadset(‘filename’, SUB{i},’filepath’, Subject_Path);
EEG = eeg_checkset(EEG);
end
eeglab redraw;I’m trying to create a loop that can load and preprocess EEG data sets, here is my code and the reoccuring error
[ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, 0 );
%% Get the list of subjects to load:
dataset = uigetdir;%allows user to manually select the folder where the data sets are stored
subjectlist = dir(dataset);
subjectlist = subjectlist(~ismember({subjectlist.name},{‘.’,’..’}));
SUB = {subjectlist(:).name};
filepath = {subjectlist(:).folder};
%%
%load data
for i = 1 : length(SUB)
% 0. Select subject id:
%subject = subjectlist(i);
% Print info to the command window
% display(‘Processing Subject %sn’, SUB(i));
%Define subject path based on study directory and subject ID of current subject
Subject_Path = filepath{i};
Subject_Path = convertCharsToStrings(Subject_Path);
% 1. Load subject data:
% subject_data = load_subject_data(cfg,subject);
[ALLEEG EEG CURRENTSET ALLCOM] = eeglab;
EEG = pop_loadset(‘filename’, SUB{i},’filepath’, Subject_Path);
EEG = eeg_checkset(EEG);
end
eeglab redraw; I’m trying to create a loop that can load and preprocess EEG data sets, here is my code and the reoccuring error
[ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, 0 );
%% Get the list of subjects to load:
dataset = uigetdir;%allows user to manually select the folder where the data sets are stored
subjectlist = dir(dataset);
subjectlist = subjectlist(~ismember({subjectlist.name},{‘.’,’..’}));
SUB = {subjectlist(:).name};
filepath = {subjectlist(:).folder};
%%
%load data
for i = 1 : length(SUB)
% 0. Select subject id:
%subject = subjectlist(i);
% Print info to the command window
% display(‘Processing Subject %sn’, SUB(i));
%Define subject path based on study directory and subject ID of current subject
Subject_Path = filepath{i};
Subject_Path = convertCharsToStrings(Subject_Path);
% 1. Load subject data:
% subject_data = load_subject_data(cfg,subject);
[ALLEEG EEG CURRENTSET ALLCOM] = eeglab;
EEG = pop_loadset(‘filename’, SUB{i},’filepath’, Subject_Path);
EEG = eeg_checkset(EEG);
end
eeglab redraw; eeglab, error MATLAB Answers — New Questions