How to create a GUI in matlab?
Show older comments
Hello everybody,
i am not very experienced in matlab.
I have to create a GUI that a gui that should make me enter:
input: a file (of any extension) and the numerical values of some variables (ex: x coordinates, y coordinates, size_map)
output: an .hdr file that contains these numeric values associated with the input file
i'm using gdal in matlab
How can I do?
4 Comments
Jan
on 13 Sep 2022
It is not clear, what you call "mask" and how it is related to the "input file". The operator "->" is not defined in Matlab also. So what does "-> (x_min, x_max, y_min, y_max, pixel_size)" mean?
Add more details by editing the question, not by appending comments. Thanks.
Harry Smith
on 13 Sep 2022
Image Analyst
on 13 Sep 2022
Sounds like you totally overlooked or ignored my answer below. Why?
Harry Smith
on 13 Sep 2022
Answers (1)
Image Analyst
on 13 Sep 2022
You forgot to attach your input file, probably because you never read the community guidelines or this link:
So if the file is a binary image, you can do
mask = imread(filename);
[rows, columns] = find(mask);
x_min = min(columns);
x_max = max(columns);
y_min = min(rows);
y_max = max(rows);
To get the pixel size you're going to have to get that somehow, like from spatial calibration or the header of the image. Otherwise, any spatial analysis will just give you results in pixels, which really doesn't have a size, or maybe you just want to consider it as 1. But if you want real world units, you have to calibrate like shown in my attached demo.
9 Comments
Harry Smith
on 13 Sep 2022
Image Analyst
on 13 Sep 2022
Admit it, you didnt' read the link I gave you. I can tell.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Harry Smith
on 14 Sep 2022
Jan
on 14 Sep 2022
@Harry Smith: You cannot provider an input file. The description of the GUI you want to create is very lean. It is not clear what exactly "the numerical values of some variables" and ".hdr file that contains these numeric values associated with the input file" exactly means.
You mention "gdal" but the readers have to guess, what this is and how it is related to your problem.
Again: Consider the tutorial concerning asking questions, which can be answered. Currently all we know, is that you want to create a specific GUI and that you are not sure how it should look like and what it should exactly do. BAsed on these details it is not possible to assist you.
Split the problem into small parts and solve one after the other. Start with deciding if you want to create a figure or uifigure, and if you want to create the GUI programmatically or using the tools GUIDE or AppDesigner. Then implement a button, which open a dialog for choosing a file.
If you have specific questions for this part of the solution, come back and ask again.
Harry Smith
on 15 Sep 2022
Image Analyst
on 15 Sep 2022
Harry Smith
on 15 Sep 2022
Image Analyst
on 15 Sep 2022
It should be. Write a small demo that proves this to me. Here are the steps you should do:
% Read your existing table.
t = readtable(filename)
% Now alter one field to have a different value.
t.Whatever(1) = someNewValue;
% Now call write table and save to a different text file.
filename2 = 'answers.txt'
writetable(t, filename2)
Then attach the code and both text files with the paperclip icon.
Harry Smith
on 15 Sep 2022
Categories
Find more on Standard File Formats in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!