I kind of need some guidance for how to manipulate structures: And here's the work i have up to the point. I want to work with databases and practice my skills, but I'm having some problems. I need a functionality to sell a particular item in the database and then reflect its changes from the inventory. So if I sold a Pencil Sharpener instead of (100) it would be (99)

Manually I know I could do Products(1) or Products(1).Name/nItems
or maybe removing by rmfield

+Three separate files

%Main Script #1

clear,clc

Products = struct('Name',[],'SKU',[],'Retail',[],'nItems',[]) %Creates Empty Structure


Products.Name = 'Pencil Sharpener' % Product Name
Products.SKU = '123456789' %SKU Number
Products.Retail = 0.3000 %Product Price
Products.nItems = 100 %Number of items in stocky


save mProduct.mat %Saves my workspace for this script

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
%Main Script 2
load mProduct.mat %Loads workspace from the first script

%Infinite while-end loop (1 == True)
while (1)
%Create a menu of options. (Given to us in the Lab)
fprintf('\n0 - Exit \n');
fprintf('1 - Add \n');
fprintf('2 - Modify \n');
fprintf('3 - Sell \n');


%Input a choice number (0-2)
choice = input('\n Please enter your choice:');

switch choice%Switches to choice case

%The user selects an option and the system displays the corresponding answer (Given to us in the lab)
case 1
pName = input('Product Name:','s'); %Input Product Name
pSKU =input('Product SKU:','s'); %Input SKU
pRetail =input('Retail Price:'); %Input Retail Price
pItem = input('Inventory Number:'); %Input Item Inventory
x = length(Products); %Length of Books Structure
Products(x+1) = makeEntry(pName,pSKU,pRetail,pItem) %Makes a new entry for the next book
case 2
disp('Want to Modify A Product?')
fprintf('4 - Products \n');
fprintf('Please Enter a specific Product by doing Products.Name,SKU,Retail,Item');
case 4
Products(1)
case 3
y = input('Please input product to sell:')
Products = Products(1).nItems-1
case 0
fprintf('Quitting! \n'); %Print message "Quitting!" %Quits the Menu
break

%If the user enters a value outside the [1 2] range, the system displays the error message "Invalid Entry"
%Could also use disp('Invalid Entry')
otherwise
error('Invalid Entry')


end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Function file makeEntry.m
function [p] = makeEntry(pName,pSKU,pRetail,pItem)
%Makes a function that will help create a new entry

%Our inputs are run through our function to get a new field in our
%structure

p.Name = pName
p.SKU = pSKU
p.Retail = pRetail
p.nItems = pItem

end