Depending on how long fresh produce spends in storage and at the market before getting to you, frozen produce might be better than fresh because produce that is to be frozen is typically frozen within hours of harvest. Fresh produce typically sits days to months in storage before finally being sold in the store. During this time nutrients break down in heat.
Canned produce varies. Canning also typically occurs soon after harvest, but requires a lot of heat and can require salt or sugar for preservation. The amount of sugar or salt used for preservation is typically higher than a healthy amount to consume. Thus the Jolly Green Giant gives you three green beans for your serving. Some nutrients break down in high heat and some are made more accessible. You will get more lycopene from a canned tomato than a store bought fresh tomato.
When you buy fresh produce, try to buy it in season if possible, and try visiting farm stands and farmer’s markets. Despite frozen food’s bad reputation, some vegetables taste just as good from frozen as they do fresh. For canned goods, read labels to make sure you’re not consuming excessive sugar or sodium.