I receive the error: Error: File: globalmin.m Line: 5 Column: 15 The expression
ID: 3873867 • Letter: I
Question
I receive the error: Error: File: globalmin.m Line: 5 Column: 15
The expression to the left of the equals sign is not a valid target for an assignment.
Explanation / Answer
PLEASE CREATE globalmin.m and PASTE BELOW CODE
function [yMin, index] = globalmin(Func,xStart,xEnd)
x = linspace(xStart,xEnd,668);
y = Func(x);
yMin = min(y);
index = find(y == yMin);
end
PLEASE CREATE test.m and PASTE BELOW CODE FOR TESTING FUNCTION
close all
clear all
clc
f = @(x) x.^2 + 4;
xStart = 1;
xEnd = 100;
[yMin,index] = globalmin(f,xStart,xEnd)
RUN test.m AND YOU WILL GET BELOW OUTPUT
yMin =
5
index =
1
>>
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.