how to fix error for unrecognized function.
Afficher commentaires plus anciens
function [eqPrice, clearedBuyQuantity, clearedSellQuantity, socialWelfare] = marketClearing(buyPrice,buyQuantity,sellPrice,sellQuantity)
nBuyOrders = length(buyPrice);
nSellOrders = length(sellPrice);
cvx_begin
variable clearedBuyQuantity(nBuyOrders);
variable clearedSellQuantity(nSellOrders);
dual variable eqPrice;
minimize(sellPrice*clearedSellQuantity-buyPrice*clearedBuyQuantity);
subject to
0 <= clearedBuyQuantity <= buyQuantity;
0 <= clearedSellQuantity <= sellQuantity;
eqPrice : sum(clearedSellQuantity) - sum(clearedBuyQuantity) == 0;
cvx_end
socialWelfare = -cvx_optval;
bus1Data = readmatrix(p1Bus1Data.csv);
bus2Data = readmatrix(p1Bus2Data.csv);
3 commentaires
James Tursa
le 22 Fév 2024
Modifié(e) : James Tursa
le 22 Fév 2024
Please post the entire error message. What you have posted doesn't even look like valid MATLAB syntax.
Juan
le 22 Fév 2024
Walter Roberson
le 22 Fév 2024
You need to have defined values for buyPrice, buyQuantity, sellPrice, and sellQuantity before you call the function.
Réponses (1)
bo zhang
le 22 Fév 2024
0 votes
When you try to run the ‘marketClearing.m’ file directly, your MATLAB workspace does not have the input variables for the function. So the error message shows that the function or variables are unrecogized. You need to find and run the main function file that calls the 'marketClearing' function.
From your code, it is also evident that the MATLAB CVX toolbox is necessary if you want to run this code properly.
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
