rand() 函数返回值来自于哪个分布?a = rand(1, 11);
b = sort(a);
c = b(1, ceil(end/2));
while 循环的正确语法?a = 0;
do
a = a + 1;
while a < 5
end
a = 0;
while(a < 5)
a = a + 1;
a = 0;
while a < 5:
a = a + 1;
a = 0;
while a < 5
a = a + 1;
end
b 包含什么?a =
19 20 12 0 6
6 9 56 0 3
46 8 9 8 19
9 8 8 19 46
1 9 46 6 19
b =
56 0
9 8
b =
8 19
19 46
myfun,想要测量运行它所需的时间。哪个代码段将返回 t,即 myfun 运行所需的秒数?t = cputime(myfun());
tic;
myfun();
toc;
timer.start;
myfun()
t = timer.stop;
t = timer(myfun());
%% 用于什么?. 字符用于以下哪个目的?mean、median 和 mode 返回相同的值?x = [-1:0.1:1];
y = X.^2;
plot(x, y)
plot 之前没有立即调用 figure,你的图形没有显示在一个图形窗口中。 plot 语法不正确。 name 的值?i 有哪个内置定义?a = [1 2 3; 4 5 6];
b = zeros(size(a));
for i_row = 1:size(a, 1)
for i_col = 1:size(a, 2)
b(i_row, i_col) = a(i_row, i_col)^2;
end
end
c 的值是多少?a = ones(1,3);
b = 1:3;
c = conv(a,b)
3]
switch 语句的正确语法?x = 7;
switch x
case 2
disp("two");
otherwise
disp("not two");
end
x = 7;
switch x :
case 2
disp("two");
otherwise
disp("not two");
end
x = 7;
switch x
case 2
disp("two");
else
disp("not two");
end
x = 7;
switch x
case 2
disp("two");
default
disp("not two");
end
a = 1;
b = 2;
c = 3;
d = 4;
e = c / (~a - b == c - d);
c =
NaN
c =
Inf
c =
-0.2500
eq 函数。 f10 中的最终结果与其他三个不同?f10 = 1;
for i = 1:10
f10 = f10 * i;
end
f10 = factorial(10) f10 = 1;
i = 1;
while i <= 10
i = i + 1;
f10 = i * f10;
end
f10 = prod(1:10) a = rand(5);
round(a * inv(a))
diag(ones(5, 1)) identity(5) eye(5) dog =
name: 'Bindy'
breed: 'border collie'
weight: 32
dog = struct('name', 'Bindy'; 'breed', 'border collie'; 'weight', 32); dog.name = 'Bindy';
dog.breed = 'border collie';
dog.weight = 32;
dog = {
'name' : 'Bindy',
'breed' : 'border collie',
'weight': 32;
}
dog('name') = 'Bindy';
dog('breed') = 'border collie';
dog('weight') = 32;
Sure, I can translate the questions to Chinese. Here they are:
my_func 是一个函数,如下所示。代码结束时,a 的值是多少?function a = my_func(a)
a = a + 1;
end
------------------
a = 0;
for i = 1:3
my_func(a);
end
a = my_func(a);
c = {["hello world"]} {1×1 cell} {["goodbye"]} {1×3 double}
{"hello world" {"hello"} "goodbye" [1 2 ]}; {"hello world" {"hello"} "goodbye" {[1 2 3]}}; {"hello world" {"hello"} "goodbye" [1 2 3]}; {"hello world" {"hello" "hello"} "goodbye" {[1 2 3]}}; b 添加到 a 的每一行?a = ones(4, 4);
b= [1 2 3 4];
a 替换为 o?for i = 1:length(fruit)
fruit{i}(fruit{i} == a) == o;
end
for i = 1:length(fruit)
fruit(i)(fruit(i) == 'a') == 'o';
end
for i = 1:length(fruit)
fruit{i}(fruit{i} == 'a') == 'o';
end
for i = 1:length(fruit)
fruit{i}(fruit{i} == 'a') == 'o';
x^2 + 2x - 4 的根?a 添加到 1x2 维度单元数组 C 末尾的正确语法?height 的 100 x 1 数组中。哪个语句会返回一个 100 x 1 数组 sim_height,其值来自于具有与身高数据相同均值和方差的正态分布?menu 的字符串中包含 'burger' 的单元数组?menu = {'hot dog' 'corn dog' 'regular burger' 'cheeseburger' 'veggie burger'}
a 可能包含的可能值集合是什么?a = randi(10, [1, 10]);
a(3) = 11;
a(a>2) = 12;
sparse 函数从单元数组变量中移除空单元格。 sparse 函数要求其输入是至少有 50% 零元素的完整矩阵。 a = 1:10;
menu 转换为下面的 menu_string 变量?menu = {'hot dog' 'corn dog' 'regular burger' 'cheeseburger' 'veggie burger'}
menu_string =
'hot dog
corn dog
regular burger
cheeseburger
veggie burger'
rng_settings_curr = rng('shuffle'); rng(time());
rng_settings_curr = rng();
rng_settings_curr = rand('shuffle'); rng('shuffle');
rng_settings_curr = rng();
data 的矩阵,其中每一列都是你房子里一个房间的单声道音频录制。你注意到每一列的均值都非常不同,并且当你将它们都绘制在同一图上时,y 轴上的分布使得几乎看不到任何东西。你想要从每列中减去均值。哪个代码块会完成这个任务?data_nomean = bsxfun(@minus, data, mean(data)); data_nomean = zeros(size(data));
for i = 1:size(data, 1)
data_nomean(i, :) = data(i, :) - mean(data(i, :));
end
data_nomean = zscore(data'); C 中每个数组的均值的数组 b?b = zeros(1, size(C, 2));
for i_C = 1:size(C, 2)
b(i_C) = mean(C(i_C));
end
b = cellfun(@mean, C); b = zeros(1, size(C, 1));
for i_C = 1:size(C, 1)
b(i_C) = mean(C{i_C}(:));
end
b = cellfun(@(m) mean(m(:)), C) passwords 中的元素包含数字,则为 1,否则为 0?passwords = {'abcd' '1234' 'qwerty' 'love1'};

figure
x = rand(10,10);
r = corrcoef(x);
surf(r)
colorbar
figure
x = rand(10,10);
r = corrcoef(x);
imagesc(r)
colorbar
a = 1:10;
b = a(randi(10, 1, 10)); m = perms(a);
i = randi(factorial(10), 1);
b = a(m(i, :))
[s, j] = sort(rand(10, 1));
b = a(i);
b = a(randperm(10));
a = 'stand'
b = "stand"
C = {'dog' 'cat' 'mouse'}
D = {'cow' 'piranha' 'mouse'}
E = setdiff(C,D)
x = 9.0646 6.4362 7.8266 8.3945 5.6135 4.8186 2.8862 10.9311 1.1908 3.2586
y = 15.4357 11.0923 14.1417 14.9506 8.7687 8.0416 5.1662 20.5005 1.0978
coeff_line = polyfit(x,y,1)
x_line = floor(min(x)):0.1:ceil(max(x));
y_line = polyval(coeff_line,x_line)
figure; plot(x,y,'o')
hold on
plot(x_linemy_line)
figure
plot(x,y,'o')
coeff_line = polyfit(x,y,1);
x_line = floor(min(x)):0.1:ceil(max(x));
y_line = polyval(coeff_line,x_line);
plot(x_line,y_line)
figure
plot(x,y)
coeff_line = polyfit(x,y,1);
x_line = floor(min(x)):0.1:ceil(max(x));
y_line = polyval(coeff_line,x_line);
hold on; plot(x_line,y_line)
coeff_line = polyfit(x,y,1);
x_line = floor(min(x)):0.1:ceil(max(x));
y_line = polyval(coeff_line,x_line);
figure; plot(x,y,'o')
hold on
plot(x_line,y_line)
a = [0 1 2 3; 4 5 6 7];
a = a^2;
___ 表示相同的位置?function mystery_func(a) :
return a
function b = mystery_func(a)
b = a;
end
def b = mystery_func(a)
b = a;
end
function mystery_func(a)
b = a;
return b;
end
a 的状态是什么?a = [1 2; 3 4];
b = a(:,2);
c = b + 3;
a(1:2,1) = c;
a =
6 3
7 4
a =
5 2
7 4
a =
5
7
a =
6
7
h_f = figure; set(h_f,'Color', [0 0 0]); h_a = gca; set(h_a,'Color', [0 0 0]); h_a = axes; set(h_a,'Color', [0 0 0]); h_f = gcf; set(h_a,'Color', [0 0 0]); 2*[1:5]+1 1:2:9 isodd(1:9) 1:odd:9 imfilter命令对图像和矩阵执行卷积操作。假设你已经在MATLAB中将图像加载到变量img中,并应用了以下代码。原始图像出现轻微模糊,因为卷积使图像平滑(去除噪声)。你认为为什么会发生这种情况?h = ones(5,5)/25;
imshow(imfilter(img,h));
h 是一个高斯滤波器,总和为1。它的预期效果是突出图像边缘。 h 是均匀分布的平均滤波器,总和为1。它的预期效果是平滑图像(去除噪声)。 h 是一个拉普拉斯滤波器,总和为0。它的预期效果是平滑图像(去除噪声)。 imfilter 是一个始终模糊图像的函数。 b 的大小是多少?a = [1 2 3];
b = repmat(a,2,3);
a?a = [ 1 2 3 4];
c = [7,8,9] c = [7: 8: 9] c = [7; 8; 9] c = [7 8 9] who vars whos who all snap的新函数,当你调用它时,你得到了你不希望得到的输出。你之前写过一个名为snap的不同函数,你认为它可能也在搜索路径上。你可以使用哪个命令来查看是否调用了旧的snap函数?-v7.3标志保存MAT文件的原因是什么?
a = randn(1,1000); histogram(a) ylabel('counts') a = rand(1,1000); histogram(a) ylabel('counts') a = randi(1,1000); histogram(a) ylabel('counts') a = rng(1,1000); histogram(a) ylabel('counts') s="abcd"; s(3)='x'
c = [9 8 0];
d = [0 0 1];
e = union(c,d);
e = [0 0 1 9 8 0] e = [9 8 0 0 0 1] e = [0 1 8 9] 8 9]`
a = 1;
for i_loop = 1:6
disp(a);
end
111111
1 1 1 1 1 1
1
1
1
1
1
1
什么都不会打印
b = ['stand' 'alone'];
c = {rand(20,10) rand(23,2) rand(14,5)}
b = cellfun(@(m) mean(m(:)), C
b = zeros(1, size(C,1);
for i_C = 1:size(C,1)
b(1_C) = mean(C{i_C}(:));
end
b = cellfun(@mean, C)
b = zeros(1, size(C,2);
for i_C = 1:size(C,2)
b(1_C) = mean(C(i_C));
end
if else语句语法?if (a > 1):
b = 2;
else:
b = 3;
if (a > 1){
b = 2;
} else{
b = 3;
}
if (a > 1)
b = 2;
else
b = 3;
end
if (a > 1)
b = 2;
else
b = 3;
a = [9 8 8 19 6 1 9 6 6 19];
b = unique(a);
b = [1 6 8 9 19] b = [1 6 8 9] b = [1 6 6 6 8 8 9 9 19 19] b = [1 6 6 8 8 9]