top of page
Forest Road

All the Code You Need

The following code was created by Lucille Ketterer (me) to be used for informational purposes only. Cannot be edited or republished.

Formatiting will translate correctly into .m or .mlx file.

Copy Code into MATLAB

%% Official Code

 

answer = questdlg('Do you want to lower your carbon footprint?', 'This is an easy one.', ...

    'Yes!','No, I do not want to help our planet.','Yes!');

 

switch answer

 

    case 'Yes!'

        disp('You are a rockstar. Thanks for caring about our planet. Now let us see what you can do.')

        planet = 1;

    case 'No, I do not want to help our planet.'

        roughness = {'Here are some considerations from the book "How Bad are Bananas?"';...

            '1. "We are in a climate emergency."';...

            '2. "It is human-made."';...

            ['3. "And we can do something about it."' ...

            'While there are other greenhouse gases, carbon dioxide has the most irreversible, long-term effects.']}

            planet = 2;

            return

end

 

answer = questdlg('How many tons of carbon would you like to offset?', ...

    'Big Decision :)','0-10','11-100','Over 100','0-10');

 

footprint = imread('https://3blaws.s3.amazonaws.com/images/iStock_000014351447Medium.jpg');

imshow(footprint)

 

switch answer

    case '0-10'

        disp(['You will need to plant 1 hectare of trees to offset ' ...

            'between 7 and 10 tons of CO2 in one year. Which type of tree to plant is covered in the next section.'])

        carbon = 1;

    case '11-100'

        disp(['You will need to plant 3-10 hectare of trees to offset ' ...

            'between 7 and 10 tons of CO2 in one year. Which type of tree to plant is covered in the next section.'])

        carbon = 2;

    case 'Over 100'

        disp(['You will need to plant over 10 hectare of trees to offset ' ...

            'between 7 and 10 tons of CO2 in one year. Which type of tree to plant is covered in the next section.'])

        carbon = 3;

end

 

land = {'northwest','west','midwest','southwest','southeast','midatlantic','northeast'}

region = menu('What part of the US do you live in?',land(1),land(2),land(3),land(4),land(5),land(6),land(7))

 

tree = imread('https://st3.depositphotos.com/1071184/13486/v/380/depositphotos_134861500-stock-illustration-hand-holding-green-small-plant.jpg?forcejpeg=true');

imshow(tree)

 

if region == 1

    disp("Plant firs of conifers.")

elseif region == 2

        disp("Plant hardwoods, conifers, oaks, or firs.")

elseif region == 3

            disp("Plant conifers, spruce, firs, aspen, birch, elm, " + ...

                "cottonwood, maple, beech, oak, or hickory.")

elseif region == 4

                disp("Plant junipers, hardwoods, elm, ash, cottonwood, " + ...

                    "conifers, oak, or hickory.")

elseif region == 5

                    disp("Plant spruce, firs, oak, gum, cypress, " + ...

                        "southern pines, oak, or hickory.")

elseif region == 6

                        disp("Plant oak, hickory, tropical hardwoods, or southern pine.")

elseif region == 7

                            disp("Plant maple, beech, birch, oak, pine, " + ...

                                "gum, cypress, spruce, or firs.")

end

 

pros = {'Yes','Nope'};

benefits = menu('I can show you some other benefits to planting trees. Want to see?','Yes','No');

 

if benefits == 1

    roughness = {['These are sourced from Professor Brynhildur Bjarnadottir at the ' ...

        'Univ. of Akureyri, Iceland.'];...

        '1. Trees prevent erosion.';...

        '2. They break wind, providing shelter for towns and farms.';...

        '3. Trees control water flow, preventing mudslides.';...

        '4. They provide habitat for animals';...

        '5. Their timber can be used locally to decrease foreign imports.'}

    if benefits == 2

        disp('Let us move on then.')

    end

end

   

Sequestration_Methods = ["Direct Air Capture (DAC)";"Carbon-Friendly " + ...

    "Agriculture";"Injection into Basalt"];

                           

answer = questdlg(['Would you like to see other ways to lower your carbon footprint? ' ...

    'They have higher costs, but eliminate more CO2 than trees do.'],'Yes or No','Yes','No','Yes')

 

        switch answer

 

            case 'Yes'

                disp(['Consider the following ways to lower your carbon footprint. ' ...

                    'While most are geared toward higher funded projects, I have easy options ' ...

                    'below for individuals.'])

                Sequestration_Methods

                lower = 1;

            case 'No'

                disp('Bummer.See you next time then.')

                lower = 2;

                return

        end

 

answer = questdlg(['Are you interested in DAC, carbon-friendly ' ...

    'agriculture, or injection into basaltic rock?'],'Select one.','Direct Air Capture', ...

    'Carbon-Friendly Agriculture','Injection into Basalt','I am not interested.')

 

artificial = imread('https://www.irishtimes.com/polopoly_fs/1.2323002.1440077809!/image/image.jpg_gen/derivatives/ratio_1x1_w1200/image.jpg');

imshow(artificial)

 

switch answer

 

    case 'I am not interested.'

        disp('No hard feelings. Happy tree planting.')

        return

        capture = 1;

 

    case 'Direct Air Capture'

        roughness = {'Quick Facts';

            ['(1) Cost per Unit: While companies can purchase their own plant ' ...

            'for about $15 million, the more popular option used by companies like Microsoft ' ...

            'is to purchase offsets. These cost about $600 per ton. To purchase offsets ' ...

            'for your company or friends, go here.'];...

here

            ['(2) Feasibility: We know DAC is feasible, because countries around the world are ' ...

Feasibility

            'implementing its technology, the US included. In fact, by 2024, the United States will have ' ...

            'the largest DAC plant in the world, capturing one million tons of CO2 annually. Smaller companies are ' ...

            'investing not in their own plants, but in offsets. For example, United Airlines pledges to become ' ...

            'carbon neutral by 2050 with DAC.'];...

            ['(3) Types of DAC: Broadly speaking, DAC falls into four categories. They include liquid + storage ' ...

            'and liquid + use, as well as solid + storage and solid + use. To learn more about these, refer to the ' ...

            'industrys leaders: Climeworks, Carbon Engineering, and Global Thermostat.'];...

            ['(4) Description: Direct air capture absorbs CO2 directly from the atmosphere. ' ...

            'From there, it can be stored underground, used in food processing, or blended with hydrogen ' ...

            'to make synthetic fuels. Artificial trees are just one upcoming form of direct air capture. ' ...

            'They use a sorbent to capture ambient CO2 from the air, promising the potential for a ' ...

            'net zero or negative emmision economy. While artificial trees are not yet on the market, ' ...

            'Climeworks has begun to run their own DAC plant. They are now building commercial plants ' ...

            'with the ability to capture 1 million tons of CO2 per year. For a video ' ...

            'explaining the process, click here.'];}

here

        capture = 2;

 

    case 'Carbon-Friendly Agriculture'

        roughness = {'Awesome! Here are some Quick Facts to get you started:';

            ['(1) Cost per Unit: Researhers estimate carbon farming costs between $10-$100 per ton. ' ...

Researhers

            'This is a tenth of the cost for mechanical CO2 removal. Its importance cannot be ' ...

            'understated, as a recent atricle from Nature said it represents "25% of natural climate solutions." ' ...

            'One could also calculate the cost on a per hectare basis. Restoring agricultural land would ' ...

            'cost a few dozen dollars per hectare. Agroforestry would need about double the investment. ' ...

            'However, its carbon payoff is also much larger.'];...

Nature

            ['(2) Feasibility: With 520 million farms across the world, the target audience is large. ' ...

            'And luckily, carbon-friendly agriculture can take different forms depending on who you are or where you are located.' ...

            'It is estimated that once regenerative ag is practiced, carbon remains in the soil for 20-30 years. ' ...

            'If you are not in ag, but want to help, consider purchasing another form of offset. Because there is not yet a ' ...

            'standardized system for measuring carbon in soil, your dollars are better put elsewhere.'];...

            ['(3) Description: This approach is for farmers and gardeners only. With half of Earths land ' ...

            'covered by agriculture and a third of GHGs coming from ag, we need ways to farm in a carbon-friendly' ...

            'way. The best thing you can do to help is increase carbon storage in the soil. This "stabilizes the' ...

            'climate and supports food production". For an informative video, click here.'];}

 

            incentive = imread('https://www.gannett-cdn.com/presto/2021/04/18/PWWF/8a7609ff-ad70-4676-807f-6e26ebc8b97e-04132021_tab1.png?width=1588');

            imshow(incentive)

 

production

here

       

        answers = {'Yes';'No'};

       

        soil = menu('Would you like to see a list of ways to keep carbon in your soil?',answers(1),answers(2));

            if soil == 1

                roughness = {'Carbon-Friendly Soil Practices';

                '(1) Practice no-till farming. This prevents carbon from getting released back into the atmosphere.';...

                '(2) Diversify crops.';...

                ['(3) Raise crops and livestock together. ' ...

                'The manure will act as a fertilizer in  the next growing season.'];...

                ['(4) Avoid leaving the soil bare. Instead, plant legumes, ' ...

                'perennials, and cover crops during the offseason..'];...

                '(5) Do not endorse deforestation, especially in the rainforest.'}

            elseif soil == 2

                disp('Oh well. Here is a website with all the goodies if you change your mind.')

website

            end

capture = 3;

 

    case 'Injection into Basalt'

 

        basalt = imread('https://www.researchgate.net/profile/James-Dooley-2/publication/228656988/figure/fig6/AS:668557549527056@1536407949519/Distribution-of-major-basalt-formations-in-the-United-States-along-with-distribution-of.jpg');

        imshow(basalt)

 

        roughness = {'Great region! Here are some Quick Facts:';

            ['(1) Cost per Unit: After a few pilot studies, scientists estimate the cost of carbon injection ' ...

Cost per Unit

            'into basaltic rock to be around $30 per metric ton. Studies have not yet been done to find the ' ...

            'price on mafic and ultramafic rock.']; ...

            ['(2) Feasibility: The following yellow regions have the potential for carbon injection. ' ...

            'See map for clarity.']; ...

            ['(3) Description: With companies like Carbfix, CO2 can be mineralized' ...

            'into carbonate rock in just a few years. It starts when carbon dioxide is ' ...

            'released from a point source like a power plant. The CO2 is then captured' ...

            'and dissolved in water to make a Bubbly of sorts. This carbonated water gets injected ' ...

            'into suitable underground rock formations, such as basalt. And what do you get? ' ...

            'Stable carbonate rock. The CO2 is now trapped for milennia.' ...

            'For a quick video, click here.'];}

 

        injection = imread('https://d9-wret.s3.us-west-2.amazonaws.com/assets/palladium/production/s3fs-public/styles/full_width/public/thumbnails/image/Carbon%20Mineralization%20Map_0.jpg?itok=CXr_N7cS ');

        imshow(injection)

here

website

Carbfix

https://www.carbfix.com/

capture = 4;

end

 

answer = questdlg(['Are you interested in purchasing carbon credits? ' ...

    'This is the perfect solution for those who cannot swing the other forms of ' ...

    'sequestration.'],'Purchase Credits?','Yes','No','Yes')

 

switch answer

    case 'Yes'

        roughness = {'Options to offset your carbon:';...

            '1. Arbor Day Tree Foundation';...

Arbor Day Tree Foundation

            '2. Climeworks CO2 Removal'}

        offset = 1;

    case 'No'

        disp('Thanks for considering it.')

        offset = 2;

end

 

answer = questdlg(['This final section reviews ways you can lower your ' ...

    'personal carboon footprint.'], 'Interested?','I am in!','Not Now','I am in!');

 

switch answer

   

    case 'Not Now'

        disp(['Thanks for spending time on this questionairre. I hope it helps ' ...

            'you (and I) lend a hand to our planet. It sure does need ' ...

            'awesome people like you.'])

        finale = 1;

    case 'I am in!'

            roughness = {'Ideas for Us:';

Ideas

            ['(1) For every serving of red meat consumed, we emit 6.61 lbs of carbon into the atmosphere. ' ...

            'Try eating more poultry and veggies. They footprint is almost nonexistant.'];...

            ['(2) If we bought $100 worth of new clothes every month, that would put ' ...

            '1/2 a ton of CO2 into the air annually. Second-hand shops like Goodwill have timeless '...

            'pieces and help support the jobs and economy of your local community.'];...

            ['(3) Every 1,000 miles in the air contributes 0.45 tons of CO2. Try taking ' ...

            'fewer, but longer international and domestic trips. If you must make them, fly direct ' ...

            'and buy offsets. A flight from NYC to LA would cost a mere $43 to offset.'];...

            ['(4) Running the dryer 5x/week emits a 1/2 ton of CO2 per year. Opt to hang ' ...

            'them outside in the lovely summer months. As an added bonus, your electric ' ...

            'bill will see a pleasant drop.'];...

            '(5) Bike or walk whenever possible. It sets off endorphins too!';...

            ['(6) Buy food grown close to home. Neighborhood farmers markets stimulate ' ...

            'your own economy AND decrease food miles. If able to swing organic, opt for that as well.'];...

            '(7) Purchase Energy Star products. They have proven energy efficiency.';...

            ['(8) This is for you folks in New Jersey (just kidding). Slow down on the aggressive ' ...

            'driving. It consumes 40% more fuel than steady driving.']}

        finale = 2;

end

 

Climeworks CO2 Removal

bottom of page