https://es.mathworks.com/matlabcentral/answers/questions?term=tag%3A%22negative +数字% 22 MATLAB的答案——新问题匹配标签:“负数” 2020 - 11 - 19 - t05:49:49z 标签:es.mathworks.com, 2005:问题/ 652088 2020 - 11 - 18 - t13:06:09z 2020 - 11 - 19 - t05:49:49z 负数的0 你好,十年后再次使用matlab的用户;有困难和提高一个负数的0次方。我认识到:(2)^ 0 = 1和2 ^ 0 = 1。在我的代码中,我试图填充5 x5,行,行填列元素的一个1 x5行向量的另一个1 x5向量。我写了一个非常基本的,可能效率低下的方法有两个for循环,但当涉及到提高一个负数0和存储它,我得到1而不是我认为是正确的;1。我想我缺少一些非常基本的,但真的很感谢任何帮助;谢谢你!k = [0:4] x =(-2.0 3.0 - 9.0 2.0 - 25.0) =的(5,5);行= 1:长度(k)坳= 1:长度(k)(行)上校= x (col) ^ k(行); end end This is what I get: But I think the top left should be -1 since -2^0 = -1 1 1 1 1 1 -2 3 9 2 25 4 9 81 4 625 -8 27 729 8 15625 16 81 6561 16 390625 西蒙•亨特 https://es.mathworks.com/matlabcentral/profile/authors/19166937 标签:es.mathworks.com, 2005:问题/ 491518 2019 - 11 - 17 - t05:48:38z 2019 - 11 - 17 - t06:37:59z 显示与“我”,而不是负面结果负号 你好,我是相当新的Matlab和我认为的解决方案与流,但我不确定。我的任务是写一个程序来确定n根2 < n < 99和任意数量在-10000000年到10000000年之间。我不允许使用Matlab的SQRT函数。负数显示他们已经使用一个我而不是一个负号(我不是3例3)。老师从来没有说我们不能使用nthroot函数,但是以防我写两套如果代码非常相似。我在一个数量的零次方(例81 ^ 1/2 = 9)一切都好,直到我放在一个负数。然后我得到两个结果。然后在其他程序使用nthroot函数答案是显示为负,而不是我,我不知道如何将这些答案。这是我的代码。谁能帮忙吗? Thanks in advance Program 1: n=input ('enter a number between -10,000,000 and 10,000,000: '); if n<-10000000 || n>10000000 disp('error on input number'); pause exit end r=input ('enter the nthroot to be calculated: '); if r<2 || r>99 disp('error on input number'); pause exit end rr=(1/r); a=n^rr Program 2: n=input ('enter a number between -10,000,000 and 10,000,000: '); if n<-10000000 || n>10000000 disp('error on input number'); pause exit end r=input ('enter the nth root to be calculated: '); if r<2 || r>99 disp('error on input number'); pause exit end a=nthroot(n,r) 琳恩生气 https://es.mathworks.com/matlabcentral/profile/authors/16077931 标签:es.mathworks.com, 2005:问题/ 468884 2019 - 06 - 25 - t21:28:11z 2019 - 06 - 26 - t14:43:59z 如何将0 xffff 1 ? 我与Matlab控制DAC。我想显示我的电压设置DAC。DAC电压范围从-10到10 v和DAC将输入值作为有符号整数。如果我投0 xffff int16 Matlab给我maxint(32767)或者如果我丢在int32得到65535。例如:DACsetting = hex2dec(“飞行符”)%显示设置流(% d \ n, DACsetting * 10 / (2 ^ 15 1));我可以写书的额外代码来解决这一问题,但这应该是一个非常简单的一门语言。DACsetting = hex2dec(“飞行符”)DACsetting = 65535 > >流(% d \ n, DACsetting * 10 / (2 ^ 15 - 1)) 2.000031 e + 01流(% d \ n, int16 (DACsetting) * 10 /(2 ^ 15 - 1))提前1谢谢。 斯蒂芬·加尔佩林 https://es.mathworks.com/matlabcentral/profile/authors/15720104 标签:es.mathworks.com, 2005:问题/ 467697 2019 - 06 - 18岁t13:53:38z 2019 - 06 - 19 t02:24:07z 把负数和行从一个数组 下午好,我要做的是找到并删除所有负2列的数组中的每个矩阵及其corrosponding行,只留下积极的。我用的代码无法实现这个总有问题涉及超过数的数组。你能帮吗?% %水槽找到大小山峰[n m] =(水槽);data_flume = [];%王是我的最后一列= 2:m %排除第1列(pks{我},idx{我}]= findpeaks(水槽(:,我));我data_flume{}(: 1) =水槽(idx{我});data_flume与其{我}(:,2)={我}(:);1;%作品确定峰值及其位置如果isempty (data_flume{我});data_flume{我}=南; % Column 26 will be blank as their are no peaks, this is to fill it in. end data_flume{i}([data_flume{:,2}]<0,:)=[] % Code will not remove negative values and their rows end %% Alterative code to remove negative values for j = 1 : numel( data_flume ) data_flume_pos = data_flume{j}(:,2) < 0 ; data_flume{j} = data_flume{j}(~data_flume_pos,:) ; % Or data_flume{j}(data_flume_pos,:) = [] ; end 理查德•里斯 https://es.mathworks.com/matlabcentral/profile/authors/10516972 标签:es.mathworks.com, 2005:问题/ 170525 2015 - 01 - 19 t11:19:06z 2015 - 01 - 19 t11:26:16z 在MatLab如何使用负数吗 我命令成绩=[1,2,3,4,5,6,7,8,9,3,4,5,2.5,-1.5,-1.8,3、8、4、4、3.5、2、6.7、4、8、4、2、1]成绩=成绩'如果成绩(我,:)< -1.5 gradesFinal(我)= 3;但MatLab并不nr.转换为3,因为它应该。是什么错了吗? 马蒂尔德Engell https://es.mathworks.com/matlabcentral/profile/authors/6025546 标签:es.mathworks.com, 2005:问题/ 157871 2014 - 10 - 08 - t16:45:03z 2014 - 10 - 08 - t22:19:27z 为初学者的for循环吗? 我很难找出一个for循环命令。我想做一个matlab脚本,它允许用户输入一个行向量,然后输出一个新的向量的0和1。对负数0和1的非负数。到目前为止,我所是:v =输入(输入向量的元素:\ n);%后进入v, i = 1运行以下代码:长度(v)如果v(我)> 0 sprintf (v (% 1) > 0, i) elseif v (i) < 0 sprintf (v(% 1) < 0,我)但是当我完成,我得到了“错误:意想不到的MATLAB的表情。”So I guess I just need to know where I'm going wrong and what I need to do differently. I'm not sure how to make the loop output it when it's done either. Thanks in advance for your help! edit: I also tried: v=input('Enter elements of vector: \n'); % after entering v,run below code for i = 1:length(v) if v(i) > 0 v(i)=1 elseif v(i) <0 v(i)=0 else v(i)=0 end end which also doesn't work. I'm not sure how to get the program to replace the values from the old vector with 0's and 1's based on whether or not they are positive. Thanks again. 安德鲁Ardolino https://es.mathworks.com/matlabcentral/profile/authors/5743797 标签:es.mathworks.com, 2005:问题/ 157759 2014 - 10 - 08 - t02:16:30z 2014 - 10 - 08 - t04:27:43z 帮助与向量和For循环和确定无论是正面的还是负面的? 使用一个for循环遍历一个向量,并创建一个新的向量B,包含逻辑值。新向量应该包含适用于积极的价值观和假的所有其他值。例如,如果:=(-300 -63 5 4 0 -46)然后结果应该B =(假真的真的假的真的真的假的)程序应该提示用户输入向量。用户输入的输入向量可以任何规模的程序应该输出原来的向量和向量逻辑值。基本上我需要允许用户输入一个变量,然后使用一个for循环来检查每一个变量是否他们是积极的吗?v =输入(“请输入向量:\ n”)这是我。提前感谢你的帮助! ! 安德鲁Ardolino https://es.mathworks.com/matlabcentral/profile/authors/5743797 标签:es.mathworks.com, 2005:问题/ 129361 2014 - 05 - 13 - t05:57:13z 2014 - 05 - 13 - t06:26:17z 试图访问B(25日1);索引必须是一个正整数或逻辑。 rowsCI =行(swtCI);B =排序(PQMatx (:, 3));h = 1;虽然h < = rowsCI;乌兰巴托= (1-swtCI (h, 1));UBB =乌兰巴托/ 2;UBBB = 1-UBB;UBBBB = UBB * swtN;J = B (UBBBB, 1);swtCI disp(“上界(1)我的); disp(J); M = B((((1-swtCI(h,1))/2)*swtN),1); disp('Lower Bound for swtCI(i,1)'); disp(M); h=h+1; end; this is my code. why cant matlab access and display negative numbers? Sameer https://es.mathworks.com/matlabcentral/profile/authors/5279278 标签:es.mathworks.com, 2005:问题/ 26540 2012 - 01 - 19 t19:11:17z 2012 - 01 - 19 t19:11:17z 删除负数 嗨!所以我一直使用MatLab的两天,我需要一些帮助。我有一个矩阵,包含积极的和消极的数字和我想删除负数通过添加最负数的绝对值的所有数字矩阵。我不知道事先最负数的价值,所以我不能硬编码。ie。矩阵是矩阵B: A = (4 0 6 3), B =[10 6 0 3]有一个简单的一步解吗?或者我需要首先找到最小值,得到绝对值,然后将其添加到所有的矩阵值?谢谢你! https://es.mathworks.com/matlabcentral/profile/authors/3278860